I created a pulse animation using CABasicAnimation, It's working perfectly but my problem is when I go to the home screen or going to another storyboard and getting back to the app or the storyboard that contains the pulse animation the pulse animation is paused, so here is the code I use to make the pulse animation
CODE:
pbt.layer.transform = CATransform3DMakeScale(1.2, 1.2, 1);
CABasicAnimation *pulsy = [CABasicAnimation animationWithKeyPath:@"transform"];
pulsy.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
pulsy.autoreverses = YES;
pulsy.duration = 0.45;
pulsy.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pulsy.repeatCount = HUGE_VAL;
[pbt.layer addAnimation:pulsy forKey:@"pulseAnimation"];
Add this line of code:
pulsy.removedOnCompletion = NO;
So your code will be :
pbt.layer.transform = CATransform3DMakeScale(1.2, 1.2, 1);
CABasicAnimation *pulsy = [CABasicAnimation animationWithKeyPath:@"transform"];
pulsy.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
pulsy.autoreverses = YES;
pulsy.duration = 0.45;
pulsy.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pulsy.repeatCount = HUGE_VAL;
pulsy.removedOnCompletion = NO;
[pbt.layer addAnimation:pulsy forKey:@"pulseAnimation"];