How to adjust an UIButton's imageSize?

前端 未结 16 2259
时光说笑
时光说笑 2021-01-29 21:40

How can I adjust the image size of the UIButton? I am setting the image like this:

[myLikesButton setImage:[UIImage imageNamed:@\"icon-heart.png\"] forState:UICo         


        
16条回答
  •  心在旅途
    2021-01-29 22:12

    If I understand correctly what you're trying to do, you need to play with the buttons image edge inset. Something like:

    myLikesButton.imageEdgeInsets = UIEdgeInsets(top: 30, left: 30, bottom: 30, right: 30)
    

提交回复
热议问题