如何设置UIButton背景色的动画 [英] How to animate UIButton background color

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

问题描述

我想将UIButton背景颜色从黑色更改为白色.但是我想在动画中更改它.例如...黑色>灰色>白色.在iPhone SDK中,有没有简单的方法可以做到这一点?谢谢你.

I want to change the UIButton background color from black to white color. But I want to change it in animation. For example... black > grey > white. Is there any simple way to do so in iPhone SDK? thank you.

推荐答案

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 300, 50)];
    [button setTitle:@"hi" forState:UIControlStateNormal];
    [button setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:button];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:2.5];
    button.backgroundColor = [UIColor whiteColor];
    [UIView commitAnimations];

这篇关于如何设置UIButton背景色的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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