UISearchBar scopebar tint color issue - iphone

While using uisearchbar with scope bar the tint color of scope bar is not updating in iOS 4.3.In remaining iOS versions it is working perfectly.I have shown the screenshot of that sample here.Any ideas to solve this please.

for (id subview in yourSearchDisplayController.searchBar.subviews )
{
if([subview isMemberOfClass:[UISegmentedControl class]])
{
UISegmentedControl *scopeBar=(UISegmentedControl *) subview;
[scopeBar setSegmentedControlStyle:UISegmentedControlStyleBar];
[scopeBar setTintColor: [UIColor redColor]];//you can also set RGB color here
//scopeBar.tintColor = [UIColor blackColor];
}
}
Also see my answer from this link for modify the UISearchBar component
How to change inside background color of UISearchBar component on iOS

If I remember correctly, it was not possible to change a tint of the scope bar. One solution could be to search all the subviews of the search bar and find the scope bar object and try to modify its background. But this might lead you to modifying private property so it might not be acceptable. I was trying going this way but I abandoned it, not sure why.
Other not so clean solution would be to implement the scope bar by yourself and add it as a subview to the search bar and block the original scope bar. Do this only for the iOS 4.3 or less.

Change the tint color for changing color of scope bar. Note BarTintColor is different - this will change the color of the search bar.

Related

iOS7 navigationBar and TabBar Color is behaving strangely

This is what I want. It loads on some of my view controllers.
Hi all,
I am going nuts trying to make the tint color of all of my viewControllers the same. Some appear to be much darker than others. All I want is the light color to be throughout...
Sometimes I get this ugly dark gray instead... I am not sure what I am doing incorrectly. I have checked the .m file and am not setting the tint color or anything... not sure why it wouldnt be consistent on every viewController...
Any help would be great. Thanks!
in iOS7 navigation bar is by default translucent=YES so just change to NO like bellow:-
self.navigationController.navigationBar.translucent=NO;
and set Navigaitonbar color or other property customize like Bellow put this code into Appdelegate class didFinishLaunchingWithOptions and use appearance for applying Globally:-
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
[[UINavigationBar appearance]setTintColor:NavigationColor];
} else {
[[UINavigationBar appearance]setTintColor:[UIColor whiteColor]]; // it set color of bar button item text
[[UINavigationBar appearance]setBarTintColor:[UIColor GreenColor]]; // it set color of navigation
[[UINavigationBar appearance] setBarStyle:UIBarStyleDefault]; // it set Style of UINavigationBar
[[UINavigationBar appearance]setTitleTextAttributes:#{UITextAttributeTextColor : [UIColor whiteColor]}]; //It set title color of Navigation Bar
// Load resources for iOS 7 or later
}
For tabBar also same this is by default translucent=YES change to NO
[self.tabBarController.tabBar setTranslucent:NO];
A common mistake is setting the view.backgroundColor of the View Controller to clearColor (both programmatically or via Storyboard). This makes the view actually black instead (since there's nothing beneath the clear view), so everything that is above that view, that has translucent property set to YES, will show dark grey color (black color + default iOS blur).
To fix this, either set the translucent property to NO (as Nitin Gohel said), or set the view.backgroundColor to white, which's its actual default color.
Hope this still helps someone!
Since iOS 7.1 there's a bug, which causes UITabBar to not listen to Global Tint.
See this post: https://stackoverflow.com/a/22323786/1255674
You need to set the tint programmatically. Thanks, Ive ...

Why does my UINavigationBar change colors when I run my app?

I'm building an iPad app using storyboards. In Interface Builder (XCode 4.5), the nav bar is the default (light grey) color...
However, when I run the app, it changes color to a dark grey...
Has anyone else had this problem? No matter what color I set it to in Interface Builder, it always ends up dark grey when I run it.
Thanks so much in advance for your wisdom!
In iOS 6 the status bar have the same color as the navigation bar.
You can customize that, according to the answers to this question:
How to change Statusbar on Modal Views iOS 6
You can colorize your navigation bar with the following line of code, just use it and you nav bar is always light gray:
[[navController navigationBar] setTintColor:[UIColor lightGrayColor]];
When you set the navigation bar color in interface builder, this only affects the view you get in IB itself, it is only a design help. The real color you have to set in code.

edit/done button, change done button background color

I have a UITableView with a navigation bar on the top. I changed the style of the navigation bar to Black Opaque to go with my theme.
I added an edit button as well using the below line of code
self.navigationItem.leftBarButtonItem = self.editButtonItem;
All is fine so far, the edit button also appears in the balck opaque style.
however the done button appears in the default blue theme. Am i missing some simple thing? How should i change it?
Help would be appreciated
The done button is always blue on a UIBlackBarStyle Navigation bar, but will adjust its color if you use the tintColor property of the navigationBar to color it in your chose of colors. I haven't tried it, but an idea would be to set
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
this should give you a Black navigation bar with a black done Button.
However, for consistency reasons you can not directly set your custom background color on the done button.

Customize moreNavigationController

I am trying to customize the moreNavigationController in a UITabBarController. I have been reading a lot of posts and guides to style this and I have managed to change the tint color of the navigation bar and the background color of the table view but there are still a few things that I would like to customize.
I have changed the tint color and the background like this:
tabcontroller.moreNavigationController.navigationBar.tintColor = [UIColor orangeColor];
tabcontroller.moreNavigationController.topViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"tableview-background-blue.png"]];
tabcontroller.moreNavigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"tableview-background-blue.png"]];
I would like to change the seperate color (the border) of the UITableView. I would also like to change the tint color of the navigation bar which appears when clicking "Edit". Also it would be great if I could change the language of the whole thing (the "More" and the "Edit" tab and so on)
Would these changes be possible and if so, do you know how?
I think you can't change the names of this tabs, which are predefined. I'm taking about the Edit button & the more tab.

How to set the Transparent statusbar in iphone

In my application i want to set the statusbar transparent.There are three styles are possible for changing the style of the statusbar.
gray
black
black translucent
mycode:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
How to set the transparent statusbar?
The best solution for this problem is to set self.wantsFullScreenLayout = YES; in your view controller and [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; for your status bar.
UPDATE:
As Mihir Oza told in comments the UIStatusBarStyleBlackTranslucent constant from old version of my answer is now deprecated. Use UIStatusBarStyleLightContent instead.
For the global app in the info.plist add Status bar style: Transparent Black Style (alpha 0.5).
The best way of doing this is with info.plist. Have a look at Apple's UIKit pList keys, specifically UIStatusBarStyle (and the value UIStatusBarStyleBlackTranslucent) for making it translucent, or the UIStatusBarHidden key (for hiding it totally).
It's not possible to make the status bar transparent. There are only 3 possible styles (gray, black and black translucent) you can set and you cannot get the bar's UIView.
However if you have static content behind it (i.e. a fixed part of your UI that you can edit) you can set the status bar to black translucent and add a 50% white layer just behind the bar. This makes the bar appear to be transparent.
Here's an example of what I mean.
See an example http://cl.ly/7WST/Untitled-1.png
In the info.plist set status bar style Transparent black style (alpha of 0.5).
In viewcontroller.xib set size fullscreen and status bar none.
In viewcontroller.m add following codes in viewWillAppear:
self.view.frame = CGRectMake(0,0,320,480);
This worked for me.
You can only hide the status bar using Status bar is initially hidden property in your info.plist