我试图隐藏 NSSecureTextField 的闪烁光标。我已经尝试过
[[passwordField.cell fieldEditorForView:passwordField] setInsertionPointColor:[NSColor clearColor]];
但它不起作用。
这个问题我也尝试过很多答案 NSTextField - White text on black background, but black cursor但无法完全隐藏它。
最佳答案
这是用 Swift 编写的,但它对我有用:
if let cell = secureTextField.cell() as? NSTextFieldCell {
if let editor = cell.fieldEditorForView(secureTextField) {
editor.insertionPointColor = NSColor.whiteColor()
}
}
哦,我发现唯一的区别是我使用 NSColor.whiteColor()
而不是 clearColor()
。
关于macos - NSSecureTextField 隐藏光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29470252/