How do I scale a UIButton's imageView?

前端 未结 19 2942
刺人心
刺人心 2020-12-02 05:16

I created a UIButton instance named \"button\" with an image using [UIButton setImage:forState:]. The button.frame is larger than the image\'s size.

Now

19条回答
  •  一整个雨季
    2020-12-02 06:02

    Storyboard

    You must define specific property in Runtime Attributes of Identity inspectorimageView.contentModel, where you set value relatively to rawValue position of enum UIViewContentMode. 1 means scaleAspectFit.

    And button's alignment, in Attributes inspector:

提交回复
热议问题