Initial app load tab bar tint blinking - ios

When iOS application starts then all tab bar icons have default tint (light blue). I setup my own custom tint color in viewDidLoad. But it applies with delay and I see transition between default tint color and my custom tint color. How can I apply my custom tint color to tab bar before interface will appear and eliminate color blinking?

override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Set the tint here after the view has been loaded completely
}

So this is because the default is set when the application finishes launching, and then is changed when your view controller is initialized. To do this, you want to change the tab bar tint globally.
Do this in your AppDelegate.m file in the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method.
Use [[UITabBar appearance] setBarTintColor:(UIColor *)]; to set the tint of your tab bar across the entire application, where (UIColor *) is of course replaced by the color you want.
Hope this helps.

Related

iOS - How to change color of icons in tab bar moreViewController

I want to change color of icons (and probably badge) in moreNavigationController from gray to something else.
I've read and successfully changed color of background and text. I did this by "replacing" data source of moreViewController (described e.g. here Customizing the More menu on a Tab bar ). But updating icons (also textLabel value) here makes no effect. Is it possible to change this gray color to white (or anything else)? Or I have to implement my own tabBarController? (any good tutorials?)
PS. I know how to change icons on tab bar itself, the question is how to do this in moreViewController?
Thanks!
Piotr
In case it is still relevant to anyone.
You can change icon colors displayed in a tableView of moreViewController:
self.tabBarController?.moreNavigationController.topViewController?.view.tintColor = UIColor.redColor()
Changing a title is like so:
self.tabBarController?.moreNavigationController.navigationBar.topItem?.title = "MyString"
Changing Edit button:
self.tabBarController?.moreNavigationController.navigationBar.tintColor = UIColor.redColor()
You can do this using the appearance proxy, new in iOS 5. In your app delegate's didFinishLaunching method:
[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
In iOS 7 use:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
See the UITabBar class reference for more details.
Ok, from long research on the web and answers in this thread, it seems that it is not possible on iOS7 to change color of the icons (gray color) displayed in moreViewController of UITabBarController. The best solution for customizable tab bar is to implement it (or use some library).
Thanks!
You can change the color, just subclass the tab bar controller and in it's view did load add the below code
override func viewDidLoad() {
super.viewDidLoad()
var view = self.moreNavigationController.topViewController.view as UITableView
view.tintColor = Utilities.mainColor()
view.separatorStyle = .None
}
For more you can see my question here : Change tint color of tabbar edit view controller

issue setting the tint / translucency level in my navigation bar iOS 7

I am trying to get a nice translucent dark navigation bar for my view. The background image is a nice black and white, so the automatic translucency in the app should be enough, but when I run the app, I get an almost 100% opaque white navigation bar.
I have reviewed many of the questions on the site and tried much of the provided answers without luck, I have looked at this:
Achieving bright, vivid colors for an iOS 7 translucent UINavigationBar'
and this
http://www.appcoda.com/customize-navigation-status-bar-ios-7/
But I still don't get the solution I am seeking, the closes I got was when the view initially appears it has the right levels, as soon as the segue comes to an end, the navigation bar becomes completely opaque. This is the code that I am trying to work with right now:
self.navigationController.navigationBar.alpha= .8f;
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
self.navigationController.navigationBar.translucent = YES;
and this is the the result I am getting:
Strangely enough, as I mentioned when the segue is presenting the view, the navigation bar has one look and when it is completely presented it has a completely different appearance, see images:
This is before the view fully loads:
and this is right after it has been fully loaded:
I would really appreciate some help, thank you.
EDIT: I tried the following code with no success :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];
return YES;
}
If you want this style for all the nag bars in your application then i suggest you set the Navigation bar style via the appearance proxy.
In your AppDelegate.m (or whatever your app delegate file is) replace the didFinishLaunchingWithOptions: method with the one below
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];
return YES;
}
Use UIBarStyleDefault for the usual light translucent bar.
Try this and tell me if it works
I believe this has been a problem since iOS 7.0.3. Try This. Use the color you used before but set the alpha = 0.67.
UIColor * navColor = ...;
self.navigationBar.barTintColor = [navColor colorWithAlphaComponent:0.67];

UISplitView remove app tint color

My app is based on a UISplitViewController on iPad.
There is a functionnality which add a second UISplitViewController over the first.
But this remove the apptint.
I've tried the following code in the first split view when going back on first split view, but it does not work:
-(void)viewWillAppear:(BOOL)animated {
UIWindow *appWindow = [[UIApplication sharedApplication]keyWindow];
[appWindow setTintColor:[UIColor redColor]];
}
I heard there is a bug (8276014 in apple bug report) that seems to match my issue.
Any help?
You can also set an app’s tint color in Interface Builder. The Global Tint menu in the Interface Builder Document section of the File inspector lets you open the Colors window or choose a specific color.
or
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.tintColor = [UIColor redColor];
return YES;
}
or
In iOS 7, tint color is a property of UIView. iOS 7 apps often use a tint to define a key color that indicates interactivity and selection state for UI elements throughout the app.
When you specify a tint for a view, the tint is automatically propagated to all subviews in the view’s hierarchy. Because UIWindow inherits from UIView, you can specify a tint color for the entire app by setting the window’s tint property using code like this:
Setting the tintColor property by using the appearance proxy APIs is not supported in iOS 7.
[[UIView appearance] setTintColor:[UIColor redColor]];//iOS 6

UIStatusBar setTranslucent:NO avoid moving content down

I am trying to get my UINavigationBar and UIStatusBar to be opaque and have no translucency properties whatsoever. I tried using [[UINavigationBar appearance] setTranslucent:NO]; but that moves the view content down a few pixels. I want that content to be under the UINavigationBar. Is there an easy way to do this?
I had the same problem when I used [[UINavigationBar appearance] setTranslucent:NO]; on AppDelegate.m . What worked for me: set "Under Opaque Bars" (see image) property in each ViewController scene under that opaque Navigation Bar
Try to change the following properties for your UIViewControllers for elimination pixels shift effect for iOS7.
First of all, translucent property just can't be set using UIAppearance. Next there is no relation between whether your bars are translucent or opaque & the changed positions of your pixels.
Customizing the Appearance of a Navigation Bar
In iOS 7, a navigation bar’s tintColor affects the color of the back indicator image, button titles, and button images. The barTintColor property affects the color of the bar itself. Additionally, navigation bars are translucent by default. Turning the translucency off or on does not affect buttons, since they do not have backgrounds.
In my IOS app, I need to do the following in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions function
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0")) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
//Added on 19th Sep 2013
self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
}
There is a more detailed discussions here ios-7-status-bar-back-to-ios-6-style

Change color of tab bar

I created an app in iOS 5 using Storyboard to lay out my screens. I have a tab bar controller and the bottom tab bar with 4 icons. I want to change the color from black to a graduated green. I can make a .png file, but can't figure out how to replace the black fill with my green fill.
I've seen some posts on code to do this but seems iOS 5 is different than if the device is running iOS4 and I can't figure out where to put the code.
Thx
Here is what worked for me:
In AppDelegate.m I put the following code after // Override point for customization after application launch.
[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
Hope this helps :)
You can either set the color on the storyboard by selecting the root: Tab Bar View Controller, select the tab bar, and adjust the Background (or tint) color in the attributes inspector, or you can adjust the code with the barTintColor:
// Adjust the Color of the Tab Bar itself
self.tabBar.barTintColor = [UIColor redColor];
// Adjust the Color of the selected Icon in the Tab Bar
self.tabBar.tintColor = [Single single].singleThemeColorTint;
If you need to adjust the ALPHA too, I would use:
UIColor *charcoal = [UIColor colorWithRed:66/255.0
green:79/255.0
blue:91/255.0
alpha:1];
// For Tab Bar
self.tabBar.barTintColor = charcoal;
// For selected Item Highlight
self.tabBar.tintColor = charcoal;
I created a View Controller File for the Tab Bar Story Board, and ran this code in ViewDidLoad{ }
Here is the wonderful blog post of Ray WenderLich.
User Interface Customization in iOS5
http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5
If you have created your application using storyboard API, then you cannot support iOS4, they rely on new runtime classes which are not available there.

Resources