我正在使用此代码创建带有背景图像的圆形边框按钮
{
Button.layer.cornerRadius = clear.frame.width/2
Button.clipsToBounds = true
Button.layer.borderWidth = 5.0
Button.layer.borderColor = UIColor(displayP3Red: 91/256, green: 87/256, blue: 115/256, alpha: 1.0).cgColor
}
这是结果:
我想在按钮和圆角边框之间为此结果创建一个边距:
提前致谢
最佳答案
您可以将其设置为 UIButton 的图像,而不是设置背景图像。
let image = UIImage(named: "imageName")
yourButton.setImage(image, for: .normal)
使用 Storyboard,来自属性检查器。
您还可以在尺寸检查器中设置内容、标题和图像插入(顶部、左侧、底部和右侧)。
关于ios - 带有背景图像按钮的圆形边框 swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50987147/