이미지가 UISegmentedControl에서 애니메이션을 적용하려고합니다. 이것은 내가 생각해 낸 것이지만 작동하지 않습니다.애니메이션 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"];