问题描述
是否可以直接从界面构建器控制 UIView 边框属性(颜色、粗细等...),还是只能以编程方式进行?
其实你可以通过interface builder来设置view层的一些属性.我知道我可以通过xcode设置图层的borderWidth和cornerRadius.borderColor 不起作用,可能是因为图层需要 CGColor 而不是 UIColor.
您可能必须使用字符串而不是数字,但它确实有效!
layer.cornerRadius图层边框宽度图层边框颜色
更新:layer.masksToBounds = true
更新:为 Keypath 选择适当的类型:
Is it possible to control UIView border properties (color, thickness, etc...) directly from interface builder or I can only do it programmatically?
Actually you can set some properties of a view's layer through interface builder. I know that I can set a layer's borderWidth and cornerRadius through xcode. borderColor doesn't work, probably because the layer wants a CGColor instead of a UIColor.
You might have to use Strings instead of numbers, but it works!
layer.cornerRadius
layer.borderWidth
layer.borderColor
这篇关于是否可以从界面构建器设置 UIView 边框属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!