How would I go about having a list of labels, and when a Round Rectangular Butt开发者_如何学Goon is pushed the UILabel above it changes to a label off the list randomly.
Assuming you've already setup your labels and defined an index to the current label in your interface, you could do something like this:
NSArray *labels = [NSArray arrayWithObjects:label1, label2, label3, nil];
int currentLabel = 0;
-(void)onButtonPress:(id)sender {
[[labels objectAtIndex:currentLabel++] removeFromSuperview];
if (currentLabel == [labels count])
currentLabel = 0;
[self addSubview:[labels objectAtIndex:currentLabel]];
}
精彩评论