新建Cocoa Touch Class,语言是swift
然后继续为界面添加一个普通的View Controller,并且添加前面视图的静态table的转向剪头指向这个View Controller,然后在这个视图上添加普通的UIView
class PositionViewController: UIViewController { //2 添加 UIView组件 的链接
@IBOutlet weak var redSquare: UIView! override func viewDidLoad() {
super.viewDidLoad() // Do any additional setup after loading the view.
} override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//
override func viewDidAppear(animated: Bool) {
//这个方法被执行的时间在生命周期中比较合适
UIView.animateWithDuration(, animations: {
self.redSquare.center.x = self.view.bounds.width - self.redSquare.center.x
})
UIView.animateWithDuration(, delay: , options: nil, animations: {
self.redSquare.center.x = self.view.bounds.width - self.redSquare.center.x
self.redSquare.center.y = self.view.bounds.height - self.redSquare.center.y
}, completion: nil)
} /*
// MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/ }
前面都是大致的简单的入门步骤,不管是什么类型的动画的方法,比如下面的透明度变化动画:

比较好的动画源代码的下载百度网址:
链接: http://pan.baidu.com/s/1jGnIC2U 密码: x4cy
github网址:https://codeload.github.com/JakeLin/iOSAnimationSample/zip/master