1

I have this code:

myButton.setBackgroundImage(UIImage(named: "image1"), for: .normal)

I'm trying to add a background for the button from the code level. I would like to set the aspect fit to this background. At the moment, the background image is not displayed properly.

ZeMoon
  • 19,626
  • 4
  • 55
  • 94
trifd
  • 93
  • 1
  • 1
  • 7

1 Answers1

3
button.imageView?.contentMode = .scaleAspectFit

It will work..for Button's background Image

Wings
  • 2,428
  • 22
  • 40