I know this is an old question, but these answers aren't correct.
When you set each separately you are saying the state
property should be UIControlStateHighlighted
OR UIControlStateDisabled
but NOT both
When you bitwise or them together you are stating they must BOTH be set in the state
property. Meaning UIControlStateHighlighted
AND UIControlStateDisabled
are set in the state
property.
The example code below perfectly illustrates my point. If you disagree run it for yourself.
[button setTitle:@"highlighted and selected" forState:UIControlStateHighlighted | UIControlStateSelected];
[button setTitle:@"Highlighted only" forState:UIControlStateHighlighted];
[button setTitle:@"Selected only" forState:UIControlStateSelected];
[button setTitle:@"Normal" forState:UIControlStateNormal];
NSLog(@"Normal title: %@", [[button titleLabel] text]); // prints title: Normal
[button setSelected:YES];
NSLog(@"Selected title: %@", [[button titleLabel] text]); // prints title: Selected only
[button setSelected:NO];
[button setHighlighted:YES];
NSLog(@"highlighted title: %@", [[button titleLabel] text]); // prints title: Highlighted only
[button setSelected:YES];
NSLog(@"highlighted and selected title: %@", [[button titleLabel] text]); // prints title: highlighted and selected
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…