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.
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)