IOS开发CABasicAnimation的基本使用

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // 建立动画对象
    CABasicAnimation *anim = [CABasicAnimation animation];
    
    // 设置动画的属性
    anim.keyPath = @"transform.scale";
    
    // 设置属性改变的值
    anim.toValue = @0.5;
    
    // 设置动画时长
    anim.duration = 0.25;
    
    // 取消反弹
    // 动画执行完毕以后不要把动画移除
    anim.removedOnCompletion = NO;
    
    // 保持最新的位置
    anim.fillMode = kCAFillModeForwards;
    
    // 重复动画的次数
    anim.repeatCount = MAXFLOAT;
    
    
    // 给图层添加了动画
    [_layer addAnimation:anim forKey:nil];
 

}
相关文章
相关标签/搜索