How to adjust an UIButton's imageSize?

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

    Swift 3:

    button.setImage(UIImage(named: "checkmark_white"), for: .normal)
    button.contentVerticalAlignment = .fill
    button.contentHorizontalAlignment = .fill
    button.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10)
    

提交回复
热议问题