Нет видимого @interface для 'UILabel' объявляет селектор addAnimation:forKey:'

Я пытаюсь добавить "пульсирующий" эффект (масштабирование / уменьшение) к метке после этого:

ios - как сделать нативную анимацию "Импульсный эффект" на 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"];

1 ответ

Решение

Это должно быть:

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

не

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

Вы должны использовать слой метки.

Другие вопросы по тегам