How to change button image in swift?
问题 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. This is what I have: @IBOutlet var tapButton: UIButton! override func viewDidLoad() { super.viewDidLoad() tapButton.setImage("redTap.png", forState: UIControlState.Normal) } But I have an error that says I can not convert string to UIIMage. How do I get it to work? I have tried: let image = UIImage(named: "redTap.png") tapButton