更改 NSTextView 默认顶部标尺的背景颜色
默认情况下,如果您将 NSTextView 添加到应用程序并转到“格式”->“文字->显示标尺,标尺将显示在文本视图的顶部,就像在 TextEdit 中一样,具有各种格式选项,并且看起来像这样:
我将如何更改该标尺的背景颜色? (标尺也应该在 10.6 上出现,甚至可能更早)
感谢您的任何提示/建议!
编辑一个:在稍微了解了标尺上对description
的调用及其子视图是什么之后,我得到了这些结果:
Description of ruler: <NSRulerView: 0x10056e580>
Orientation: horizontal, Rule thickness: 16.0
Flipped: Yes, frame: {{0.0, 0.0}, {528.0, 55.0}}, bounds: {{0.0, 0.0}, {528.0, 55.0}}
Accessory frame: {{0.0, 0.0}, {528.0, 24.0}}
Ruler's Subviews: (
"<NSStopTouchingMeBox: 0x10059b940>"
)
这是一个非常有趣的类名,是不是吗? =P
By default, if you add a NSTextView to an application and go to Format -> Text -> Show Ruler, a ruler will be shown on top of the text view like in TextEdit with various formatting options, and will look like so:
How would I go about changing the background colour of that ruler? (The ruler should also be there on 10.6, maybe even earlier)
Thanks for any hints/suggestions!
EDIT ONE: After stabbing around a bit what a call to description
on the ruler and what it's subviews are, I came to these results:
Description of ruler: <NSRulerView: 0x10056e580>
Orientation: horizontal, Rule thickness: 16.0
Flipped: Yes, frame: {{0.0, 0.0}, {528.0, 55.0}}, bounds: {{0.0, 0.0}, {528.0, 55.0}}
Accessory frame: {{0.0, 0.0}, {528.0, 24.0}}
Ruler's Subviews: (
"<NSStopTouchingMeBox: 0x10059b940>"
)
That's a pretty interesting class name, isn't it? =P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尝试子类 NSRulerView。您可以覆盖drawRect:方法并用您的颜色填充矩形。
I would try to subclass NSRulerView. You could overwrite the drawRect: method and fill the rect with your color.