I have an NSColorWell to allow the user to change the color of the text.
If I set the default to black, the NSColorPanel which appears seems a little useless to beginners, as the color wheel only shows solid black (which is normal). So I want to set the mode to, perhaps, Crayons. I can't figure out how to do this though - the color panel appears by default when my NSColorWell is clicked - how do I talk to it or intercept it to set the mode?
I needed to obtain a reference to the sharedColorPanel. To change the mode, I send the setMode message with a constant from the color panel modes enum to the sharedColorPanel.
NSColorPanel *cpanel = [NSColorPanel sharedColorPanel];
[cpanel setMode:NSCCrayonModeColorPanel]; // [cpanel setMode:7];
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSColorPanel_Class/Reference/Reference.html
Related
I noticed that many apps uses a custom global tint color like Pages (Yellow) or Music (Red). NSAlert default buttons respect this tint, as NSOpenPanel and others do (for example drop-down arrow as show in picture).
I alos noticed that NSAlert brings a delete button that shows text in red. Do you know how to get it to appear?
Thanks
How could I specify a specific global color. I create UI using code and not Storyboard.
Searching in Apple's app folders, such as Pages, I found what we need to do to change the app's overall tint.
Create a color object in the Asset;
In the info.plist add the key NSAccentColorName that is a string assigned to the color name created at step 1;
This colors NSAlert default buttons and all control's accent elements.
Where can i set color of the SwitchButton button? By default, it is white, so on the white background its looking wierd. I set all possible brushes to noteable color (blue), but button is still white.
Ideally, you probably want to just edit (or make a copy of) the original control template. Right click it, Edit Template->Edit and you can expose the objects in the template that make the background as well as the ones for the different states like MouseOver, IsChecked, etc and will allow you to do it directly to the object giving the current background. Which you often have to do if they dont have the Background property bound to the template you can specify with just Background="blah"
Which is what I would assume is the case since you have the background property set and it still doesn't show your change.
You could also expose that property in the template so from now on you could just specify Background="" by finding which object is that white background and changing its background property to;
Background="{TemplateBinding Background}"
Hope this helps.
When i set the default background for the view (the view is used as a header for the table) in IB it becomes black but when I run the app on a simulator it has the default color of the uitableview background.
When i set the default color to yellow for example it is always yellow for both IB and simulator.
why the default background color is black in IB and gray with stripes in a simulator?
Because the Interface Builder in Xcode has bugs. I assume you mean you are setting the background color to the "default" option?
I have run into several similar bugs with background color, sometimes it even sets the background color of an element that isn't supposed to have a background color. What I usually do is right click on the xib or storyboard file and Open As Source Code. Then find my element and carefully delete the background property (make a backup of the file if you are concerned about accidentally breaking the complex xml file structure). Then open it as Interface Builder again and it usually figures things out.
Or, worst case, I delete the problem element or view and recreate it.
Edit: it also occurred to me that the default color could be the clear color, in which case, the texture is showing through the view, not being drawn as the view's background, and interface builder chooses black because A) it doesn't know what the view will be drawn on top of and/or B) the view or parent view is marked as opaque or something to that effect.
I changed the background color for my app, but other elements keep the same background color.
Looks like I missed some easy configuration, bsc for NSTabViewItems item colors is deprecated by docs, and using current theme...
You can't easily adjust the tint of the standard controls. You're going to have to subclass and override the drawing code for each of the elements.
Also, may I humbly suggest that you leave it the default color?
U may use Core Animation layer in IB. Choose your object (for example button),
open the view effects inspector (⎇⌘8), set checkbox with your object, add "content filters"
color monochrome and set color! That is all!
This must have been asked before, but after Googling I still can't find the answer.
How do you change the color of the title bar (The bar that you can click and drag around with the close, minimize and maximize buttons) to a different color than the default gray in Cocoa?
If you set the background color of a "textured" window (a distinction that isn't really all that visible in Snow Leopard) that color will be applied to the titlebar as well. This is what Firefox does.
I would recommend though not having a real titlebar (i.e. setting your window to have no titlebar) and using +[NSWindow standardWindowButton:forStyleMask:] and putting your own buttons in the "titlebar". This allows you more control and is way way less hacky.
If it's a panel, you can change it to black by instantiating it as a HUD window.
Otherwise, you can't. Ever notice how there aren't any Aqua windows with different-colored title bars roaming around in other apps? This is why.
The only other way to change the appearance of the title bar (without relying on private implementation details such as the existence of a frame view) is to make the window borderless and create its title bar and window buttons from the ground up.
If you go with Colin's approach of making the window textured in interface builder (check box in the attributes of the window), here's the line to change the background color of the window you'd put in this function of the appDelegate.m file
//In this function --->
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
//type this
[_window setBackgroundColor: NSColor.whiteColor];
If you don't mind private API, you could subclass NSThemeFrame.
Setting title bar appears as transparent
self.window.titlebarAppearsTransparent = YES;
And setting window background color as you wish