Setting Content Mode of UIButton Images

130 views Asked by At

I am developing an application in swift. I have 9 buttons in my storyboard and i set the content mode of the button images in viewDidLoad() function. But it takes a few seconds to set content modes, so my page is opening a little late. Is there any way to open my page without waiting.

override func viewDidLoad() {
    super.viewDidLoad()
    sizeBtn1.imageView?.contentMode = .scaleAspectFit
    sizeBtn2.imageView?.contentMode = .scaleAspectFit
    sizeBtn3.imageView?.contentMode = .scaleAspectFit
    sizeBtn4.imageView?.contentMode = .scaleAspectFit
    sizeBtn5.imageView?.contentMode = .scaleAspectFit
    sizeBtn6.imageView?.contentMode = .scaleAspectFit
    sizeBtn7.imageView?.contentMode = .scaleAspectFit
    sizeBtn8.imageView?.contentMode = .scaleAspectFit
    sizeBtn9.imageView?.contentMode = .scaleAspectFit
}
1

There are 1 answers

0
Sanjukta On

You can try in storyboard :

enter image description here

It may helps you. Thank you