How to not stretch an image in UIButton

前端 未结 7 789
深忆病人
深忆病人 2020-12-23 11:35

I\'m trying to create a custom UITableViewCell programmatically and one of the subviews of this cell is going to be a button with an image in it (a simple image of a magnify

7条回答
  •  猫巷女王i
    2020-12-23 11:58

    Swift 4.X and 5.X

    button.imageView!.contentMode = .scaleAspectFit
    button.contentVerticalAlignment = .fill
    button.contentHorizontalAlignment = .fill
    

提交回复
热议问题