- Set the button type to
UIButtonTypeCustom(“Custom” in a storyboard or xib). - Set the button’s image, not the button’s background image.
- In
viewDidLoad, setbutton.imageView.contentModetoUIViewContentMode.ScaleAspectFill.
UIButtonTypeCustom (“Custom” in a storyboard or xib).viewDidLoad, set button.imageView.contentMode to UIViewContentMode.ScaleAspectFill.