码迷,mamicode.com
首页 > 移动开发 > 详细

iOS项目开发实战——制作视图的缩放动画

时间:2015-08-20 10:31:25      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:动画   ios   swift   缩放   

     视图的大小应该是随时可控的。今天我们就来实现对一个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)
        
        
        
    }

}

(3)运行程序,发现View可以变为原来X,Y轴上的0.5倍。

版权声明:本文为博主原创文章,未经博主允许不得转载。

iOS项目开发实战——制作视图的缩放动画

标签:动画   ios   swift   缩放   

原文地址:http://blog.csdn.net/chenyufeng1991/article/details/47803451

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!