1 -(void)touchesBegan:(nonnull NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event{ 2 3 //创建动画对象 4 CABasicAnimation *anim = [CABasicAnimation animation]; 5 //设置属性 6 anim.keyPath = @"transform.scale"; 7 //设置属性值. 8 anim.toValue = @0; 9 10 //设置动画的执行次数 11 anim.repeatCount = MAXFLOAT; 12 13 //设置动画的执行时长 14 anim.duration = 0.5; 15 16 //自动反转 17 anim.autoreverses = YES; 18 19 //添加动画 20 [self.imageV.layer addAnimation:anim forKey:nil]; 21 22 23 }
浙公网安备 33010602011771号