
CATransition和UIVIEwAnimation是场景切换时常用的两种过渡动画
目录 Swift学习笔记1过渡动画CATransition和UIViewAnimation的用法 目录 CATransition CATransition的type属性 CATransition的subtype属性 代码示例 UIViewAnimationTransition UIViewAnimationTransition的类型 UIViewAnimationTransition的类型 代码示例 CATransition CATransition的type属性:kCATransitionFade //淡入淡出(默认)kCATransitionMoveIn //移入kCATransitionPush //压入kCATransitionReveal //渐变CATransition的subtype属性:
kCATransitionFromrightkCATransitionFromleftkCATransitionFromtopkCATransitionFromBottom代码示例:
func change() { // 初始化动画的持续时间,类型和子类型 let Transition = CATransition() Transition.duration = 2.0 Transition.type = kCATransitionReveal Transition.subtype = kCATransitionFromleft let nextVIEw = self.storyboard?.instantiateVIEwControllerWithIDentifIEr("next") as! NextVIEwController self.vIEw.addSubvIEw(nextVIEw.vIEw) // 执行刚才添加好的动画 self.vIEw.layer.addAnimation(Transition,forKey: nil) } uiviewanimationtransition uiviewanimationtransition的类型: //水平翻转:FlipFromleftFlipFromright//卷页效果:CurlUpCurlDownuiviewanimationtransition的类型:
EaseInOut //动画由慢变快再变慢EaseIn //动画由慢变快EaSEOut //动画由快变慢linear //匀速动画代码示例:
func change() { let nextVIEw = self.storyboard?.instantiateVIEwControllerWithIDentifIEr("next") as! VIEwController self.vIEw.addSubvIEw(nextVIEw.vIEw) UIVIEw.beginAnimations("",context: nil) //设置动画的持续时间,类型和渐变类型 UIVIEw.setAnimationDuration(0.5) UIVIEw.setAnimationTransition(uiviewanimationtransition.CurlDown,forVIEw: self.vIEw,cache: true) UIVIEw.setAnimationCurve(UIVIEwAnimationCurve.EaseInOut) //开始动画 UIVIEw.commitAnimations() } 总结 以上是内存溢出为你收集整理的Swift学习笔记(1)过渡动画(CATransition和UIViewAnimation)的用法全部内容,希望文章能够帮你解决Swift学习笔记(1)过渡动画(CATransition和UIViewAnimation)的用法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)