如何从按钮背景中减去标题文字的形状?透明UIButton标题
我创建一个自定义的UIButton类。目前添加边框和文字颜色的代码看起来就像这样
layer.borderWidth = 2.0
layer.borderColor = buttonColor.CGColor
layer.cornerRadius = (CGFloat(bounds.height) + paddingVertical * 2.0)/2.0
setTitleColor(buttonColor, forState: UIControlState.Normal)
任何关于如何从背景减去按钮标题形状的建议。我是否需要将所有这些渲染为图像,还是有更好的选择?
如果你有这样的图像,这可以很容易地实现。 – Mrunal 2014-12-13 11:05:24
我正在寻找一个编程解决方案 – Bernd 2014-12-13 11:15:43
这里的一点点改变可能会帮助你:http://stackoverflow.com/questions/23515100/ios-uibutton-with-transparent-title-on-white-background – Mrunal 2014-12-13 11:18:50