如何使UIButton边框看起来像下面的图像(“入门”)按钮与透明背景?
如何使用故事板或如何以编程方式实现这一点?
将backgroundColor设置为clearColor使按钮变得透明.尝试下面的代码.您可以根据需要配置和更改borderAlpha,cornerRadius和颜色.
let borderAlpha : CGFloat = 0.7 let cornerRadius : CGFloat = 5.0 button.frame = CGRectMake(100,100,200,40) button.setTitle("Get Started",forState: UIControlState.Normal) button.setTitleColor(UIColor.whiteColor(),forState: UIControlState.Normal) button.backgroundColor = UIColor.clearColor() button.layer.borderWidth = 1.0 button.layer.borderColor = UIColor(white: 1.0,alpha: borderAlpha).CGColor button.layer.cornerRadius = cornerRadius