customize UIBarButtonItem in Navigation Bar - ios

I was trying to customizing the UIBarButtonItem in Navigation Bar
I found that there is a property in UIBarButtonItem : "tintColor" , and I set it like this
self.navigationItem.leftBarButtonItem.tintColor = [UIColor redColor];
It works well, but if I try this :
self.navigationItem.leftBarButtonItem.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"imageName"]];
1. It doesn't work as expect , however , the leftBarButtonItem shows a black appearance ,why ?
If I try a clearColor :
self.navigationItem.leftBarButtonItem.tintColor = [UIColor clearColor];
2. The leftBarButtonItem shows a black appearance still, why ?
3. I want to customize it with a pattern image like above , how can I do that ?
Thank you

You can check this sample code for customizing navigation bar and back button
https://github.com/boctor/idev-recipes/tree/master/CustomBackButton

Related

How to set the UISearchBar cancel button highlight color

I have a UISearchBar that is added to my view controller in a xib file.
I have the following properties set through Interface Builder:
barStyle = UIBarStyleDefault
searchBarStyle = UISearchBarStyleMinimal
translucent = YES
barTintColor = Clear Color
In code I'm styling the bar with this code, to make the text color white:
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
Also in my app delegate didFinishLoading method I have:
self.window.tintColor = [UIColor whiteColor];
My cancel button in the UISearchBar is a light grey. When I select it it highlights blue, which is jarring as it doesn't fit with any of the other visual elements in the screen. How can I change the button to highlight to a different color? Alternatively I would be fine if the cancel button was white and highlighted to a grey, like my navigation bar buttons do, but I don't know how to change the button color.
I'm targeting iOS7, using Xcode 5.
This answer seems appropriate, but it is having no effect for me https://stackoverflow.com/a/15791136/472344
Try this in Appdelegate in didFinishLaunchingWithOptions
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],UITextAttributeTextShadowOffset,nil] forState:UIControlStateNormal];
Try to set tintColor of the Search Bar. it work for me with target 8.0 xcode 5.
self.searchBar.tintColor = [UIColor blackColor];

Navigation Bar color and a View's color

I'm getting a weird, i have a navigation bar and a view that is right under it.
I set both of them to [UIColor BlueColor], but at run time the outcome is that the nav bar has a slit darker color then the view.
Any knows what causes this?
Thanks
Your problem is that the navigation bar is translucent, and therefore the bar color is put on top of the view's color, making it appear darker. Try making the bar not translucent.
navigationBar.translucent = NO;
You can try this one:--
navigationController.navigationBar.barTintColor = [UIColor greenColor];
or
[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];

iOS - Remove color on navigation and tabbar items

I want to remove the color that lays over the tab bar and navigation bar items so the icons I use will have the colors they have. Is it possible to fix this?
I am not sure it will work but you can try imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal. Example for tab bar:
UIImage *your_image; // do not forget to initialiuze it!
your_view_controller.tabBarItem.image = [your_image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
You could perhaps try:
self.tabBarController.tabBar.tintColor = [UIColor clearColor];
self.navigationController.navigationBar.tintColor = [UIColor clearColor];

change navigationbar button colors for ios7

I am trying to find out how to change the text and arrow color of the UINavigationBar buttons.
I know how to change the titleTextAttributes but cannot find out how to do it to the buttons.
For example this is how I change the titleTextAttributes inside my AppDelegate
self.navigationController.navigationBar.titleTextAttributes = #{NSForegroundColorAttributeName : [UIColor redColor]};
I have looked through the UINavigationBar docs and cannot find any button attributes so not sure what to do here.
to change the text color and the color of the arrow in the navigation bar you can use this code (iOS 7):
self.navigationController.navigationBar.tintColor = [UIColor redColor];
this code will also change the color of the buttons
You can globally change it as easy as this

Why isn't the status bar adjusting the color of its text to match my UINavigationController?

I have an app that uses a navigation bar with a dark gray background color and a white title. According to this article, under "UINavigationController and the iOS7 Status Bar", it says that it should that as long as I am using a navigation controller, the status bar should automatically adjust its text color to match it. Here is a screenshot of the top of my app:
As you can see, the navigation controller's title was set to white, so shouldn't the status bar be set to white too? Here's my code for the navigation controller's color adjustment:
UINavigationController* navStack = [[UINavigationController alloc] initWithRootViewController:mainFeed];
navStack.navigationBar.barTintColor = [UIColor colorWithRed:20/255.0f green:20/255.0f blue:20/255.0f alpha:1.0f];
navStack.navigationBar.tintColor = [UIColor whiteColor];
[navStack.navigationBar setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
You need to add this in:
navStack.navigationBar.barStyle = UIBarStyleBlack;
What that article says is a bit misleading.

Resources