Search code examples
iosxcodeuibuttoninterface-builder

How to set selected image of UIButton in XCode Interface Builder


I have two image sets for "flag" button in my Images.xcassets: flag-highlighted and flag-normal, where each set has 3 images of size x1, x2, x3

I use the flag-normal image set for the Image attribute in the attributes inspector for this button. But, where/how do I specify the flag-highlighted image set for the selected state?


Solution

  • You can set image for specific button state via interface builder by using state config option.

    State config option

    Choose selected option and then pick your image for selected state.