视图的大小应该是随时可控的。今天我们就来实现对一个View的缩放动画。该动画的实现与位移动画,透明度动画稍有不同。具体实现如下:
import UIKit class ScaleViewController: UIViewController { @IBOutlet weak var greenSquare: 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) { super.viewDidAppear(animated) func anim(){ self.greenSquare.transform = CGAffineTransformMakeScale(0.5, 0.5)//缩小为原来的0.5倍; } UIView.animateWithDuration(1, animations: anim) } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/chenyufeng1991/article/details/47803451