I am working on an app which has a button. The button has no text, image or background.
So what I want to do is to give it an image in the viewDidLoad function.
There's one simple solution:
@IBOutlet var tapButton: UIButton!{ didSet{ let image = UIImage(named: imageColor[randNum]) tapButton.setImage(image, forState: UIControlState.Normal) }
Besides that, in the Attribute Inspector, Set Button type to 'Custom'