是否可以从界面构建器设置UIView边框属性? [英] Is it possible to set UIView border properties from interface builder?
问题描述
是否可以直接从界面构建器控制UIView边框属性(颜色,粗细等等),或者我只能以编程方式进行控制?
Is it possible to control UIView border properties (color, thickness, etc...) directly from interface builder or I can only do it programmatically?
推荐答案
实际上,您可以通过界面构建器设置视图图层的某些属性。我知道我可以通过xcode设置图层的borderWidth和cornerRadius。 borderColor不起作用,可能是因为图层需要CGColor而不是UIColor。
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
更新:
为Keypath选择合适的类型:
Update: select appropriate Type for Keypath:
这篇关于是否可以从界面构建器设置UIView边框属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!