How do I prevent a button's background image from stretching?

后端 未结 10 1821
执笔经年
执笔经年 2021-01-30 16:22

I\'m allocating a UIButtonTypeCustom UIButton to a UIView with a background image that is smaller than the button\'s frame. Reason why the image is smaller is because I\'m tryin

10条回答
  •  借酒劲吻你
    2021-01-30 16:48

    It is simple as:

        ImageBn.imageView?.contentMode = .scaleAspectFit
        ImageBn.setImage(chosenImage, for: .normal)
    

提交回复
热议问题