0

the most relevant code i found was let fieldEditor = self.window?.fieldEditor(true, forObject: textField) as! NSTextView? fieldEditor!.insertionPointColor = NSColor.redColor() but doesn't work because field editor is nil i tried this using in subclass of textfield.

fahad khan
  • 89
  • 1
  • 6

1 Answers1

2

Never mind found the answer by extending NSTextField class and calling the function manually

extension NSTextField {
   public func customizeCaretColor(caretColor: NSColor) {
      let fieldEditor = self.window?.fieldEditor(true, forObject: self) as! NSTextView
      fieldEditor.insertionPointColor = caretColor
   }
}
fahad khan
  • 89
  • 1
  • 6