一张图片的尺寸比较小,想要填充到一个较大的按钮上,并且按比例填充满按钮.
代码如下:
let headButton =UIButton()
headButton.imageView?.contentMode = .scaleAspectFill
headButton.imageEdgeInsets=UIEdgeInsetsMake(0,0,0,0)
headButton.contentHorizontalAlignment = .fill
headButton.contentVerticalAlignment = .fill
headButton.setImage( imageLiteral(resourceName: "伴游_01"), for: .normal)
网友评论