iOS开发——动画编程Swift篇&(二)UIView转场动画
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)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。