我想不出使按钮看起来像下图所示的方法。
图标应该比按钮大。
我已经厌倦了这个,但它不起作用:
let image = UIImage(named: "CircleForButtonCountries")
goToCoutriesButtonMain.imageView?.contentMode = UIViewContentMode.scaleAspectFit
goToCoutriesButtonMain.setImage(image, for: UIControlState.normal)
最佳答案
试试这段代码
let image = UIImage(named: "CircleForButtonCountries")
goToCoutriesButtonMain.imageView?.contentMode =
UIViewContentMode.scaleAspectFit
goToCoutriesButtonMain.setBackgroundImage(image, for: UIControlState.normal) // use setBackgroundImage instead of setImage
关于Swift:图像大于按钮的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50030794/