为iPhone UIButton的片头动画 [英] UIBUtton title animation for iPhone

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

问题描述

我想提出一个动画自定义的UIButton的标题,这样的数字(每个标题显示了一个随机分配的数字)会来旋转。我怎样才能做到这一点?

I want to put an animation to custom UIButton's title so that the numbers (each title shows a random assigned number) will come rotating. How can i do that?

问题是我不希望做到这一点使用翻转图像数。我想知道是否有任何其他方式。

The problem is i don't want to do this using flipping number images. i am wondering if there is any other way.

推荐答案

假设你有一个名为按钮 flipLabelButton 连接为 IBOutlet中您的视图控制器,你可以使用这个code到您的按钮动画到一个新的标签:

Assuming that you have a button called flipLabelButton connected as IBOutlet to your view controller, you can use this code to animate your button to a new label:

- (IBAction)flipLabelText:(id)sender {
    NSString *newText = [NSString stringWithFormat:@"%d", rand() % 100];
    [UIView beginAnimations:@"flipbutton" context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.flipLabelButton cache:YES];
    [self.flipLabelButton setTitle:newText forState:UIControlStateNormal];
    [UIView commitAnimations];
}

这篇关于为iPhone UIButton的片头动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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