How to make a "within window" transparent/blurry title bar using a custom base color in Yosemite? - objective-c

I've been playing around with NSVisualEffectViews in Yosemite and transparent titlebars but I was wondering if it's possible to have a custom title bar, with my own base color (not that gray), that would act like Apple's.
Here's my current NSWindow:
I achieved this look by setting the following code on my custom NSWindowController:
self.window.styleMask = self.window.styleMask | NSFullSizeContentViewWindowMask;
self.window.titleVisibility = NSWindowTitleHidden;
self.window.titlebarAppearsTransparent = YES;
That blue color is just a custom NSView that's painting its rect with that particular color. The content below it is a NSTableView.
So, the goal was to actually have my titlebar to work like, let's say, Maps but instead of having the "base" color as the gray color, my "base" color would be that blue one and when the NSTableView scrolls, that content appears below my title bar.
Any ideas on how to achieve this? Thanks

Have you tried setting a blue color with a transparency of, e.g., 0.75 in the blue view, and a NSVisualEffectViewunderneath it?

Related

get navigation bar color to give it to status bar color on iOS 5

i'm new here and i actually started learning recently and i'm making my first Theos tweak (i made some with flex) and as i said in the title i'm looking for a way to get nav bar color or a color from part of the screen and apply it as the status bar background color
You're going to need to write a function to detect your targetPixelColor as a UIColor, and then apply that color to the status bar within viewWillAppear using something like
-(void)viewWillAppear:(BOOL)animated{
[self.navigationController.navigationBar setBarTintColor:targetPixelColor];
}
you should add just blow code in view didLoad.
[Example is here]I added light Gary color.you could add your own choice colour.
self.navigationController?.navigationBar.barTintColor = UIColor.lightGray

NSButton loses blue highlight effect when setting an Alternate image

When I use a NSButton with style 'Round Rect', type 'Toggle' and an image, the image and title will be nicely rendered in blue, when the State is set to On.
However, when I also add an alternate image, this highlight effect is gone.
Is there a simple way to fix this?
I want to achieve the same effect as the small tab bar icons on top of the Inspector in Xcode: blue when selected, using an alternate image (slightly bolder), black when not selected, using the default image.
This is the expected behavior. The system only transforms your template to apply the visual highlight if you don't supply your own alternate (active / lit / on) version.
While waiting for a more elegant solution, I'm using this workaround:
-(IBAction)handleClick:(id)sender
{
NSButton *button = sender;
button.image = [NSImage imageNamed:[button.identifier stringByAppendingString:button.state == NSOnState ? #"On" : #""]];
}
I toggle in code between the standard image and the alternate image, using the identifier of the control as a base name for the image. A bit ugly, but it works. The image on the button is now blue highlighted while showing the (slightly bolder) alternate image, when in 'On' state.
To NOT use an alternate image and get an NSButton (macOS 10.13) with Blue Tint when ON and not when OFF like some of the buttons in Xcode toolbar, I had to do the following:
png in asset catalog with transparent background and white line drawing.
png in asset catalog set to render as "template" (see right sidebar).
Set only 1 image. Do not use an alternate image or it no worky.
bezelstyle = NSTexturedRoundedBezelStyle.
buttontType = NSToggleButton.
I also change controlTint in the button action handler for state.

Setting UISearchBar to minimal with translucency

Is it possible to make a UISearchBar translucent with a background color and search field color that can be changed separately?
This is what I'm currently getting with a search style of minimal and a background of light blue. If I want the search field to be white, I have to not use minimal for the search style, but then my search bar isn't translucent.
What can I do?

Background color of NSSearchfield not working

I have a NSSearchField and I want to change its background color but i am not able to do it i tried out few things:
1) I tried to set DrawBackground TRUE and then setBackgroundColor but the value of DrawBackGround is always False either I try to set it trough code or Nib.(i don't know why?)
2)I tried out setting NSText's BackgroundColor but it is not looking good because it is not covering whole NSSearchField the extreme corners where the small search icon and cancel icon is present are left uncolored.
3)I want the searchField to have the color of the view it is lying so i decreased the alpha value of the searchField which looks good but the alpha value of text is also decreased so is there any way to make text's alpha value to remain always 1.
Thanks :)
If you look at the documentation, Apple prevents background color rendering for rounded-rectangle fields:
"In order to prevent inconsistent rendering, background color rendering is disabled for rounded-bezel text fields."
https://developer.apple.com/library/prerelease/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextField_Class/#//apple_ref/occ/instm/NSTextField/setDrawsBackground:
NSSearchField is extension of NSTextField, NSTextField again extension of NSView,
Not sure, but its possible to make a custom clas and overwrite drawRect function and paint with the background color.

Backgrounds for UInavigationBar and UIPickerView

I understand that when you create a navigation controller it comes with a navigation bar, you are only able to select three backgrounds for this (example: translucent black etc). I've seen applications that have other colors like green with the "translucent black" type feature. Are they simply creating their own background view's and setting it for the UINavigationBar? how do they get this "translucent" effect too? like the whole view is not a single color, but the top is like a lilttle transparent and the bottom a different color. Similar to the UIPickerView that has a nice design in the background.
How can I do this? design the graphs with a graphic design program? or simply use quartz (gradients, etc) on views to get this?
Thank you!
You can change the color by changing the tintColor property of the UINavigationBar
myBar.tintColor = [UIColor greenColor];