在这里我找到了如何使用现已弃用的 beginAnimations:context:
方法为 UIButton
的标题更改设置动画:
Here I found how to animate UIButton
's title change using now-deprecated beginAnimations:context:
method:
iPhone的UIBUtton标题动画
如何使用当前的 API 做同样的事情?
How to do the same thing using current APIs?
更新:
我尝试使用基于块的动画:
I've tried to use block-based animations:
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];
颜色变化不是动画的.
使用积木:
[UIView transitionWithView:self.flipLabelButton duration:1 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
[self.flipLabelButton setTitle:newText forState:UIControlStateNormal];
} completion:nil];
这篇关于动画 UIButton 的标题更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!