Home > Mobile >  Styling of NSTextField
Styling of NSTextField

Time:03-26

How to make border and style of NStextField like that (except icon on the right)? Is it custom or built-in?

enter image description here

CodePudding user response:

Set new CALayer and play with isBezeled and isBordered properties before setting colors.

let field = NSTextField()
field.layer = CALayer()
field.wantsLayer = true
field.isBezeled = false
field.isEditable = true
field.isBordered = true
field.backgroundColor = NSColor.white
field.layer?.borderColor = NSColor.gray.cgColor
field.layer?.backgroundColor = NSColor.white.cgColor
field.layer?.borderWidth = 1
field.layer?.cornerRadius = 5
  • Related