简体   繁体   English

NSTextField上的setBackgroundStyle,其归因字符串值不起作用

[英]setBackgroundStyle on NSTextField with an Attributed String Value not working

OS X 10.7: OS X 10.7:

Whenever I try to setBackgroundStyle: on an NSTextField 's cell that has an Attributed String value, the background style is unmodified. 每当我尝试在具有Attributed String值的NSTextField单元格上设置setBackgroundStyle: ,背景样式都是未修改的。 If the NSTextField has just a String value, the background style setter works. 如果NSTextField只有String值,则后台样式setter可以工作。

[myTextField cell] returns an object of type NSTextFieldCell in both cases, which inherits setBackgroundStyle: from NSCell . [myTextField cell]在两种情况下都返回一个NSTextFieldCell类型的对象,它从NSCell继承setBackgroundStyle: .

Anyone have a suggestion on how I can get around this limitation? 有人建议我如何解决这个限制? I know I could try to recreate it with attributes, but I may never be able to get it just right. 我知道我可以尝试用属性重新创建它,但我可能永远无法做到恰到好处。

PS - NSBackgroundStyleLowered appears to override your cell's text color (makes mine white), whereas NSBackgroundStyleRaised does not. PS - NSBackgroundStyleLowered似乎会覆盖您的单元格的文本颜色(使我的白色),而NSBackgroundStyleRaised则不会。

IME,NSAttributedString会覆盖NSTextField的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM