gpt4 book ai didi

macos - NSSecureTextField 隐藏光标

转载 作者:行者123 更新时间:2023-12-03 17:10:55 26 4
gpt4 key购买 nike

我试图隐藏 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com