【发布时间】:2010-08-24 08:17:46
【问题描述】:
我想将 UIButton 背景颜色从黑色更改为白色。但我想在动画中改变它。例如...黑色>灰色>白色。 iPhone SDK中有什么简单的方法吗?谢谢你。
【问题讨论】:
标签: iphone objective-c iphone-sdk-3.0
我想将 UIButton 背景颜色从黑色更改为白色。但我想在动画中改变它。例如...黑色>灰色>白色。 iPhone SDK中有什么简单的方法吗?谢谢你。
【问题讨论】:
标签: iphone objective-c iphone-sdk-3.0
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];
【讨论】:
属性 backgroundColor 自 3.2 SDK 起可设置动画。
【讨论】: