我试图添加一个'脉冲'效果(缩放/缩小)到此后的标签:
ios - how to do a native "Pulse effect" animation on a UIButton
但是我在XCode中收到以下错误:
No visible @interface for 'UILabel' declares the selector 'addAnimation:forKey:'
代码(.h):
IBOutlet UILabel *SecondsLabel;
代码(.m):
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
theAnimation.duration=1.0;
theAnimation.repeatCount=HUGE_VALF;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.0];
[SecondsLabel addAnimation:theAnimation forKey:@"transform.scale"];
答案 0 :(得分:2)
必须是:
[SecondsLabel.layer addAnimation:theAnimation forKey:@"transform.scale"];
不是
[SecondsLabel addAnimation:theAnimation forKey:@"transform.scale"];
您必须使用标签图层。