Change the color of the NSWindow title bar

I am developing a desktop application in which I want to change the color of the NSWindow title bar. How can i do this?

+3
source share
3 answers

To change the color of the window toolbar:

  • Set the window style to Textured in Attribute inspector.
  • In code: [window setBackgroundColor: MyCustomColor];
+5
source

The NSWindow content view has a supervisor that is an instance of NSThemeFrame. This class is responsible for drawing the title text, background texture of the window / toolbar and contains routines for everything else (close button, full-screen button, NSDocument icon, etc.).

Objective-C NSThemeFrame drawRect: , , .

, , , NSFont, .

, , () /, "" ( , ), , , , , -, -.

: https://github.com/abhibeckert/Dux/blob/master/Dux/DuxProjectWindow.m ( : , DUX_DARK_MODE == 1)

, , Mac App Store, . , OS X.

+4

, :

NSEnumerator *viewEnum = [[[[[[window contentView] superview] titlebarViewController] view] subviews] objectEnumerator];
NSView *viewObject;

while(viewObject = (NSView *)[viewEnum nextObject]) {
   if([viewObject className] == @"NSTextField") [viewObject setTextColor: .. your color .. ];
}
+1

Source: https://habr.com/ru/post/1535534/


All Articles