Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

theprizerevealed

macrumors regular
Original poster
Feb 26, 2016
183
12
I am trying to display an image inside a button, I know how to do it by using the Attributes Inspector (it works when I do it that way) but I wish to do it by manual coding also. I know to put my images in Assets.xassets.

I tried this code below but it simply displayed a colored block inside the button. Can someone help me understand what's wrong? thanks for your help.



Code:
let image = UIImage(named: "mypicture")
      
        self.button.setImage(image, for: UIControlState.selected)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.