美文网首页
动画常用属性及回调方法

动画常用属性及回调方法

作者: 心里的另一个你 | 来源:发表于2017-03-06 14:13 被阅读238次
镇楼.jpeg

常用UIView动画属性设置方法

setAnimationDelay:动画延迟执行时间间隔
setAnimationCurve:用于设置动画加速、减速效果.它是一个枚举类型:
     EaseInOut:动画开始和结束时都呈现减速效果.
     EaseIn:动画开始时呈现减速效果
     EaseOut:动画结束时呈现减速效果
     Linear:动画匀速运动
setAnimationsEnabled:动画是否使能,有ture和false两个参数.当为false时,动画效果禁止;当为ture时,动画效果使能.
setAnimationDuration:用于设置动画执行时间周期
setAnimationRepeatAutoreverses:动画是否有重复返回效果
setAnimationRepeatCount:动画重复执行次数

动画回调方法的使用

1.代理回调方法

override func viewWillAppear(_animated:Bool){
//CGAffineTransform:缩放
     UIView.beginAnimations(nil,context:nil) //动画开始
     UIView.setAnimationDelegate(self) //设置回调对象
     UIView.setAnimationDuration(1) //动画周期时间
     beautyImageView!.transform = CGAffineTransform(scaleX:0.7,y:1.2)
     UIView.commitAnimations( ) //动画提交
}

重写动画结束后的停止回调方法

override func animationDidStop(anim:CAAnimation,finished flag:Bool)
{
       print("animation stop!")
}

2.setAnimationDidStopSelector自定义回调方法

override func viewWillAppear(_animated:Bool) {
//CGAffineTransform:缩放
     UIView.beginAnimations(nil,context:nil) //动画开始
     UIView.setAnimationDelegate(self) //设置回调对象
     UIView.setAnimationDuration(1) //动画周期设置
     beautyImageView!.transform = CGAffineTransform(scaleX;0.7,y:1.2)
     UIView.setAnimationDidStop(#selector (ViewController.animationEnd))
    UIView.commitAnimations( ) //动画提交
}
func animationEnd( ){
     print("AnimationEnd!")
}

相关文章

网友评论

      本文标题:动画常用属性及回调方法

      本文链接:https://www.haomeiwen.com/subject/jvwygttx.html