更改 NSTextView 默认顶部标尺的背景颜色

发布于 2024-11-16 23:09:44 字数 716 浏览 0 评论 0原文

默认情况下,如果您将 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:

YES LIKE THIS

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫嚣ゝ 2024-11-23 23:09:44

我会尝试子类 NSRulerView。您可以覆盖drawRect:方法并用您的颜色填充矩形。

I would try to subclass NSRulerView. You could overwrite the drawRect: method and fill the rect with your color.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文