常用动画:缩放动画

一、代码如下

@property (weak, nonatomic) IBOutlet UIView *myView;
- (IBAction)show:(id)sender
{
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    [animation setFromValue:@(1.0f)];//1.缩放的开始值
    [animation setToValue:@(0.1f)];//2.所要缩放到的值
    [animation setAutoreverses:YES];//3.是否原路返回
    [animation setDuration:1.0f];//4.动画时长
    [animation setRepeatDuration:MAXFLOAT];//5.动画重复次数
    [self.myView.layer addAnimation:animation forKey:nil];
}

二、动画效果

suofang.gif

你可能感兴趣的:(常用动画:缩放动画)