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

  • 相关阅读:
    P1052 过河
    P1004 方格取数
    自定义事件
    自定义单选,多选按钮
    构造函数+原型的js混合模式
    图标
    格式化
    时间 ---- 时间简史
    居中
    插入DOM元素
  • 原文地址:https://www.cnblogs.com/A--G/p/4679316.html
Copyright © 2011-2022 走看看