我试图在 UISegmentedControl 中为图像设置动画。这是我想出的,但它不起作用。
如果我在最后一行代码中将 imageView.layer 切换为 _segmentedControl.layer,动画本身就可以正常工作。
我错过了什么?
UIImageView *imageView = [[UIImageView alloc] init];
imageView.image = [_segmentedControl imageForSegmentAtIndex:0];
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scale.duration = 0.25;
scale.repeatCount = 2;
scale.autoreverses = YES;
scale.fromValue = [NSNumber numberWithFloat:1.0];
scale.toValue = [NSNumber numberWithFloat:0.0];
[imageView.layer addAnimation:scale forKey:@"scale"];