Reputation: 89
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.
Upvotes: 0
Views: 889
Reputation: 89
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
}
}
Upvotes: 2