Search code examples
iosuibuttonselected

UIButton .selected doesn't cover whole width of button?


Edit: Here is the screenshot:

screenshot

The button on the right is selected. I'd like the color to fill the entire button.

The buttons are created on storyboard with widths pinned. I simply toggle selected/not selected with

button.selected = YES;

I have not found any similar questions about adjusting the width of the part that is selected, and I haven't been able to figure out any solutions. Any ideas?


Solution

  • Make sure your UIButton's type is "Custom", not "System".

    Custom button type