0

I'm trying to add a 'pulsing' effect (scale in/out) to a label following this:

ios - how to do a native "Pulse effect" animation on a UIButton

But I am receiving the following error in XCode:

No visible @interface for 'UILabel' declares the selector 'addAnimation:forKey:'

The code (.h):

IBOutlet UILabel *SecondsLabel;

The code (.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"];
Community
  • 1
  • 1
Friendly Code
  • 1,585
  • 1
  • 25
  • 41

1 Answers1

2

It must be:

[SecondsLabel.layer addAnimation:theAnimation forKey:@"transform.scale"];

not

[SecondsLabel addAnimation:theAnimation forKey:@"transform.scale"];

You have to use the layer of the label.

Jens
  • 67,715
  • 15
  • 98
  • 113