[NSTextView selectedTextAttributes]我的应用程序中的默认值无法使用,因为我允许用户选择与背景颜色几乎完全相同的颜色(语法突出显示).
我已经写了一些数学来确定合适的颜色,可以使用它来设置它:
textView.selectedTextAttributes = @{
NSBackgroundColorAttributeName: [NSColor yellowColor],
NSForegroundColorAttributeName: [NSColor redColor]
};
Run Code Online (Sandbox Code Playgroud)
但是当窗口在后台时,它仍然使用系统默认的浅灰色.
我已经使用活动与非活动窗口附加了上述代码的屏幕截图. - 如何更改非活动窗口的选定文本背景颜色?
