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

iOS开发——动画编程Swift篇&(二)UIView转场动画

时间:2015-06-07 23:21:21      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:

UIView转场动画

 

 1     // MARK: - UIView动画-过度动画
 2     var redView:UIView?
 3     var blueView:UIView?
 4     
 5 //    enum UIViewAnimationTransition : Int {
 6 //        
 7 //        case None
 8 //        case FlipFromLeft
 9 //        case FlipFromRight
10 //        case CurlUp
11 //        case CurlDown
12 //    }
13     
14     //上翻页
15     @IBAction func excessiveAnimationRed()
16     {
17         UIView.beginAnimations(nil, context: nil)
18         UIView.setAnimationDuration(1.0)//设置动画时间
19         UIView.setAnimationTransition(UIViewAnimationTransition.CurlUp, forView: self.view, cache: true)
20         self.view.exchangeSubviewAtIndex(1, withSubviewAtIndex: 0)
21         UIView.commitAnimations()
22     }
23     
24     //下翻页
25     @IBAction func excessiveAnimationBlue()
26     {
27         UIView.beginAnimations(nil, context: nil)
28         UIView.setAnimationDuration(1.0)//设置动画时间
29         UIView.setAnimationTransition(UIViewAnimationTransition.CurlDown, forView: self.view, cache: true)
30         self.view.exchangeSubviewAtIndex(0, withSubviewAtIndex: 1)
31         UIView.commitAnimations()
32     }
33     
34     
35     // MARK: - UIView动画-翻转
36     @IBAction func flipAnimation()
37     {
38         UIView.beginAnimations(nil, context: nil)
39         UIView.setAnimationDuration(1.0)//设置动画时间
40         UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromLeft, forView: testImageView, cache: true)
41 //        UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: testImageView, cache: true)
42         UIView.commitAnimations()
43     }

 

 创建两个视图
1         //过度动画 添加两个视图
2         redView = UIView(frame: CGRectMake(200, 70, 120, 400))
3         redView?.backgroundColor = UIColor.redColor()
4         self.view.insertSubview(redView!, atIndex: 0)
5         
6         blueView = UIView(frame: CGRectMake(200, 70, 120, 400))
7         blueView?.backgroundColor = UIColor.blueColor()
8         self.view.insertSubview(blueView!, atIndex: 1)

 

 

iOS开发——动画编程Swift篇&(二)UIView转场动画

标签:

原文地址:http://www.cnblogs.com/iCocos/p/4559277.html

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