【发布时间】:2014-09-10 01:52:14
【问题描述】:
我找不到任何与之相关的东西。我是初学者,但我假设我需要一个 NSArray 来更改颜色。
无论如何,我有一个按钮,当您单击该按钮时,它会将标签背景更改为绿色。我如何做到这一点,所以第一次单击它会将标签背景更改为绿色......然后第二次单击它将背景更改为黄色
- (IBAction)studentOne:(id)sender {
_studentOne.backgroundColor = [UIColor greenColor];
_studentOne.backgroundColor = [UIColor yellowColor];
_studentOne.backgroundColor = [UIColor redColor];
_studentOne.backgroundColor = [UIColor blackColor];
_studentOne.backgroundColor = [UIColor whiteColor];
}
这将是我的顺序。
会不会是涉及到的事情
NSArray *colorArray;
colorArray = [NSArray array with objects:
我尝试了这个,因为我认为这可能就像在单击按钮时更改文本颜色
- (IBAction)studentOne:(id)sender {
NSArray *colorArray;
colorArray = [NSArray arrayWithObjects:
@"_studentOne.backgroundColor = [UIColor greenColor]",
@"_studentOne.backgroundColor = [UIColor yellowColor]",
@"_studentOne.backgroundColor = [UIColor redColor]",
@"_studentOne.backgroundColor = [UIColor blackColor]",
@"_studentOne.backgroundColor = [UIColor whiteColor]",
nil];
}
【问题讨论】:
标签: ios xcode background