How to adjust an UIButton's imageSize?

前端 未结 16 2392
时光说笑
时光说笑 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:18

    you can use imageEdgeInsets property The inset or outset margins for the rectangle around the button’s image.

     [self.btn setImageEdgeInsets:UIEdgeInsetsMake(6, 6, 6, 6)];
    

    A positive value shrinks, or insets, that edge—moving. A negative value expands, or outsets, that edge.

提交回复
热议问题