I am trying to make a UI button a toggle button 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 get a strange artifact when the button is in the selected mode.
Not chosen:

marked:

source share