I am trying to change the image of a UIButton using Swift... What should I do
This is OBJ-C code.but I don\'t know with Swift:
[playButton setImage:[
Swift 5 and ensures the image scales to the size of the button but stays within the buttons bounds.
yourButton.clipsToBounds = true yourButton.contentMode = .scaleAspectFill // Use setBackgroundImage or setImage yourButton.setBackgroundImage(UIImage(named: "yourImage"), for: .normal)