当我使用类别方法将动画添加到我的按钮时,我无法单击该按钮,似乎它已被禁用:
[_compassCalibrateButton pulse:1.5 continuously:YES];
_compassCalibrateButton.userInteractionEnabled=YES;
我有一个 UIView 类别包含这个:
- (void)pulse:(float)secs continuously:(BOOL)continuously {
[UIView animateWithDuration:secs/2
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
// Fade out, but not completely
self.alpha = 0.3;
}
completion:^(BOOL finished) {
[UIView animateWithDuration:secs/2
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
// Fade in
self.alpha = 1.0;
}
completion:^(BOOL finished) {
if (continuously) {
[self pulse:secs continuously:continuously];
}
}];
}];
}