zoukankan      html  css  js  c++  java
  • 用layer添加UIView的动画

    项目有时会遇到用UIView 添加动画的情况,这里我觉得在layer上添加动画比较好,因为可以详细地设定动画属性,方便理解

    下面是一个旋转动画:

    -(void)roundBtnAction:(id)sender {
        
        
        UIButton * button = (UIButton *)sender;
        
        //Animation自旋转(layer动画):
        CABasicAnimation* rotationAnimation;
        
        rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
        
        rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 1 ];
        
        [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        
        rotationAnimation.duration = 1;
        
        rotationAnimation.repeatCount = 0;//你可以设置到最大的整数值
        
        rotationAnimation.cumulative = NO;
        
        rotationAnimation.removedOnCompletion = NO;
        
        rotationAnimation.fillMode = kCAFillModeForwards;
        
        [button.layer addAnimation:rotationAnimation forKey: @"Rotation"];
       
    }

    原文:http://www.cnblogs.com/A--G/p/4679316.html

  • 相关阅读:
    重谈MST及Kruskal算法
    小技巧—边权转点权
    JDOJ 1062 过路费
    总结—二分答案求解问题
    CF10D LCIS
    NOIP 2012 摆花
    SDOI 2014 旅行
    CF550C Divisibility by Eight
    CF295C Greg and Friends
    USACO Closing the Farm
  • 原文地址:https://www.cnblogs.com/A--G/p/4679316.html
Copyright © 2011-2022 走看看