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?
UIButton
instances 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 of setTitle:forState:
and set its title to @""
, or you could change the alpha property of the color to 0.0f
with setTitleColor:forState:
so it becomes transparent when the button is in the states chosen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With