动画UIButton的标题更改 [英] Animate UIButton's title change

查看:126
本文介绍了动画UIButton的标题更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我找到了如何使用now-deprecated 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的标题更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆