In a view controller I have set up the following code to initially hide a button array group:
- (void)viewDidLoad {
[super viewDidLoad];
for(UIButton * noteButtonItem in noteButtonArray){
noteButtonItem.titleLabel.hidden = YES;
//NSLog(@"Title is %@", noteButtonItem.currentTitle);
}
}
From the .h file:
@property (nonatomic,retain) IBOutletCollection(UIButton) NSArray *noteButtonArray;
And attached via IB
The initial hide works fine, but when ever I “touch” a button (in the simulator), the titleLabel doesn’t stay hidden.
What is going on behind the scenes?
Is there a way to make them stay hidden until hidden is set to YES?
UIButtoninstances can have different configurations depending on their state (states described here). If you want to hide the button’s title label in all states, you could make use ofsetTitle:forState:and set its title to@"", or you could change the alpha property of the color to0.0fwithsetTitleColor:forState:so it becomes transparent when the button is in the states chosen.