美文网首页
IOS - 常用的动画效果:UIView封装的动画,CALaye

IOS - 常用的动画效果:UIView封装的动画,CALaye

作者: GoGooGooo | 来源:发表于2016-01-05 23:24 被阅读228次
    // 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 path
    // 1> CABasicAnimation
    // * fromValue  初始值 
    // * toValue  最终值  (从初始化变化到最后某一个值)
    // * byValue  步进值  (在初始值的基础上,增加多少值)
    // 2> CAKeyframeAnimation
    // * values
    // 3> 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> 如果需要同时执行多个动画,最好选择CAAnimationGroup
    // 4> UIView动画和CALayer动画中最灵活的是CALayer的动画
    // 4.自定义一些动画
    // 用CADisplayLink,在刷帧方法完成需要执行的动画
    

    相关文章

      网友评论

          本文标题:IOS - 常用的动画效果:UIView封装的动画,CALaye

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