Use opacity.
UIButton *btnTest = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btnTest.frame = CGRectMake(0, 0, 100, 100);
[btnTest setTitle:@"Breathe" forState:UIControlStateNormal];
[btnTest addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnTest];
CABasicAnimation *fadeAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.fromValue=[NSNumber numberWithFloat:0.7];
fadeAnimation.toValue=[NSNumber numberWithFloat:1.0];
fadeAnimation.duration=1.0;
fadeAnimation.repeatCount=INFINITY;
fadeAnimation.autoreverses=YES;
[btnTest.layer addAnimation:fadeAnimation forKey:@"fadeInOut"];
source
share