I'm trying to make a UI Button a toggle button by using this code:
- (void)tapButton:(id)sender{
UIButton *button = sender;
if (!button.selected){
[self performSelector:@selector(highlight:) withObject:button afterDelay:0.0];
}else{
[self performSelector:@selector(removeHighlight:) withObject:button afterDelay:0.0];
}
}
- (void)highlight:(UIButton *)button{
button.selected = !button.selected;
button.highlighted = YES;
}
- (void)removeHighlight:(UIButton *)button{
button.selected = !button.selected;
button.highlighted = NO;
}
However, I'm getting a weird artefact when the button is in selected mode.
Not selected:
Selected:
Just make the button type to be "custom" instead of "system". I guess this weird bug is related to the new Tint feature on iOS7. It's probably buggy because your title property is an empty string @"".