开发者

Change background colour of NSTextView's default top ruler

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:

Change background colour of NSTextView's default top ruler

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜