在这里,我找到了如何使用现已弃用的beginAnimations:context:
方法来动画化UIButton
的标题更改:
如何使用当前的API实现相同的效果?
更新:
我尝试使用基于块的动画:
NSTimeInterval animationDuration = animated ? 1.f : 0.f;
[UIView animateWithDuration:animationDuration delay:0.f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:^{
[button setTitle:newTitle forState:UIControlStateNormal];
[button setTitleColor:newTitleColor forState:UIControlStateNormal];
} completion:nil];
颜色变化不带动画效果。