iOS常用的一些动画效果,UIView封装的动画,CALayer的动画等

来源:互联网 发布:stc单片机下载不了 编辑:程序博客网 时间:2024/04/28 15:08
1.UIView封装的动画1> 首尾式[UIView beginAnimations:nil context:nil];// ... 需要执行怎样的动画[UIView commitAnimations];2> block[UIView animateWithDuration:0.5 animations:^{    // 需要执行的动画} completion:^(BOOL finished) {    // 动画完成}];3> 转场动画(过渡动画)// 让某个view执行转场动画[UIView transitionWithView:<#(UIView *)#> duration:<#(NSTimeInterval)#> options:<#(UIViewAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>];2.CALayer的动画// CABasicAnimation和CAKeyframeAnimation的keyPath可以是哪些值?// 在xcode文档搜索:CALayer Animatable Properties// transform的具体属性:搜索catransform3d key path1> CABasicAnimation* fromValue  初始值 * toValue  最终值  (从初始化变化到最后某一个值)* byValue  步进值  (在初始值的基础上,增加多少值)2> CAKeyframeAnimation* values3> CATransition(转场动画)CATransition *anim = [CATransition animation];anim.type = @"cube";anim.subtype = kCATransitionFromBottom;[view.layer addAnimation:anim forKey:nil];4> CAAnimationGroup* 动画,可以同时执行多个动画3.如何选择动画1> 如果需要重复执行多次动画,最好选择CALayer动画2> 如果动画执行完毕后,就要用到前面的一些东西,最好选择UIView的block动画3> 如果需要同时执行多个动画,最好选择CAAnimationGroup4> UIView动画和CALayer动画中最灵活的是CALayer的动画4.自定义一些动画用CADisplayLink,在刷帧方法完成需要执行的动画
0 0