开发者

How to animate UIButton background color

开发者 https://www.devze.com 2023-01-13 07:51 出处:网络
I want to change the UIButt开发者_开发百科on 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

I want to change the UIButt开发者_开发百科on 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];


Property backgroundColor is animateable since 3.2 SDK.

0

精彩评论

暂无评论...
验证码 换一张
取 消