, , , animationDidStop .
@property (weak, nonatomic) IBOutlet UIImageView *orangeView2;
@property (nonatomic) bool pulseActive;
@property (strong, nonatomic) CAKeyframeAnimation *pulseAnimation;
- , , , , - ( , ).
,
- (CAKeyframeAnimation *)pulseAnimation
{
if ( !_pulseAnimation )
{
_pulseAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
_pulseAnimation.values = @[ @0.0f, @1.0f, @0.0f ];
_pulseAnimation.duration = 0.5;
_pulseAnimation.delegate = self;
[_pulseAnimation setValue:@"PulseAnimation" forKey:@"AnimationIdentifier"];
}
return( _pulseAnimation );
}
- ( )
removedOnCompletion ( )delegate self, animationDidStopsetValue:forKey:
, , , animationDidStop. , forKey setValue, .
, animationDidStop. pulseActive ( ).
- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)flag
{
NSString *animationIdentifier = [animation valueForKey:@"AnimationIdentifier"];
if ( [animationIdentifier isEqualToString:@"PulseAnimation"] )
{
if ( self.pulseActive )
[self.orangeView2.layer addAnimation:self.pulseAnimation forKey:@"pulsate"];
}
}
. , ,
- (IBAction)pulseButtonPressed
{
if ( !self.pulseActive )
{
self.pulseActive = YES;
[self.orangeView2.layer addAnimation:[self pulseAnimation] forKey:@"pulsate"];
}
else
{
self.pulseActive = NO;
}
}