【发布时间】:2016-07-18 03:40:36
【问题描述】:
我的 NSTextField 有圆角和白色背景色,但看起来好像视图本身是矩形的。这意味着圆角和边界矩形之间的空间显示为透明。如何填写此区域以使其不显眼?
图片:
代码:
let textFieldLayer = CALayer()
textField.layer = textFieldLayer
textField.backgroundColor = NSColor.whiteColor()
textField.layer?.backgroundColor = NSColor.whiteColor().CGColor
textField.layer?.borderColor = NSColor(calibratedRed: 47/255.0, green: 146/255.0, blue: 204/255.0, alpha: 1.0).CGColor
textField.layer?.borderWidth = 1
textField.layer?.cornerRadius = 7
【问题讨论】:
-
你是如何精确地圆角的?
-
请出示您尝试过的代码。
-
添加了上面的代码。感谢您的帮助。
-
@user3225395 旧问题但
textField.wantsLayer = true而不是textField.layer = textFieldLayer
标签: swift macos cocoa interface-builder nstextfield