UIStatusBar setTranslucent:NO avoid moving content down - ios

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

Related

Make Navigation Bar Opaque with solid bg color

I am trying to set a solid color for the navigation bar but it always appears translucent.
None of SO answers I tried seem to work.
I have tried:
In the App Delegate:
[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:89/255.0 green:196/255.0 blue:197/255.0 alpha:1.0f]];
In my main TableviewController:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:89/255.0 green:196/255.0 blue:197/255.0 alpha:1.0f];
self.navigationController.navigationBar.translucent = NO;
}
I have also unchecked the Translucent option and checked the Opaque option in the attribute inspector.
Following is an image of what I am trying to achieve:
How do I make the navigation bar opaque with a solid background color?
Thanks.
Go to attribute inspector of for Navigation bar and remove check mark from translucent.
Please find in image.
I was also trying to figure it how to make Navigation bar background a solid color. I was trying to change background color from Storyboard - Attribute inspector but that was wrong option.
The Bar Tint color in the attribute inspector changes the background color of navigation 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

How to get the blurred and translucent effect on a navigation bar in iOS 7?

Problem
My app appears to be laid out correctly, but I cannot achieve the blurry translucent effect that iOS 7 is famous for. Mine appears opaque.
Desired Effect
I'm trying to get a more obvious blur effect such as Apple's Trailers app:
Translucency
In my subclass of UINavigationController, I make the navigation bar translucent:
- (id)initWithRootViewController:(UIViewController *)rootViewController
{
if (self = [super initWithRootViewController:rootViewController]) {
self.navigationBar.translucent = YES;
}
return self;
}
Tint Color
In my subclass of UIApplicationDelegate, I set the tint color of the navigation bar. I discovered that the alpha of the tint color makes no difference. That is, using an alpha of 0.1 would not cause the bar to become more translucent.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];
}
Edges
In my content view controller, I set the edge to UIRectEdgeNone so the top doesn't get chopped off by the navigation bar. If I were to use the default UIRectEdgeAll, the navigation bar would permanently cover the top of my content. Even if I were to live with this abnormality, UIRectEdgeAll still does not enable the translucency effect.
- (void) viewDidLoad
{
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeNone;
}
Edit: Experimenting with Edges
Ad pointed out by #rmaddy in the comments, the problem may be with the edgesForExtendedLayout. I found a comprehensive tutorial edgesForExtendedLayout and attempted to implement it:
- (void) viewDidLoad
{
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeAll;
self.automaticallyAdjustsScrollViewInsets = YES;
self.extendedLayoutIncludesOpaqueBars = NO;
}
It did not work. Firstly, there was no translucency effect. Secondly, the top of my content was chopped off. On the following example page with the above code, the avatar was initially covered by the navigation bar and it was very hard to scroll to. You could pull down to see the top of the avatar, but when you let go, the page would automatically bounce back up and the avatar would be obscured again.
The problem was caused by the third party pull-down-to-refresh view EGORefreshTableHeaderView, which was popularly used before iOS 6 introduced the system refresh control.
This view confuses iOS 7, making it think that the content is taller than it really is. For iOS 6 and 7, I've conditionally switched to using UIRefreshControl. Now the navigation bar will not chop off my content. I can use UIRectEdgeAll to make my content go underneath the navigation bar. Finally, I tint my navigation bar with a lower alpha to get the translucency effect.
// mostly redundant calls, because they're all default
self.edgesForExtendedLayout = UIRectEdgeAll;
self.automaticallyAdjustsScrollViewInsets = YES;
self.extendedLayoutIncludesOpaqueBars = NO;
[[UINavigationBar appearance] setTintColor:[UIColor colorWithWhite:0.0 alpha:0.5]];
If you need to achieve exactly the same effect as in the iTunes Store (Dark Blur).
Configure the barStyle attribute of the navigation bar as follows:
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

Is there a place to set the UINavigationBar's default color?

I am a new iOS developer working on a project that created by an ex-employee. Currently all the navigation bar is black, and I need to change them to the default blue color. So far I have figured out this line:
[self.navigationController.navigationBar setTintColor:[[UIColor colorWithHue:0.6 saturation:0.33 brightness: 0.65 alpha:1.0] autorelease]];
It worked, but I don't think it's the right way to do it. I have created a new screen too and the color is blue, so I figure there must be a setting in some place. In the xib file the Top Bar is none, and we have this code in viewDidLoad
if (self.navigationController.navigationBar.isHidden) {
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
else {
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
The question is: is there a place I can set the default color? or I have to do it programmatically.
In iOS 5 you could use Appearence to do that
[[UINavigationBar appearance]setTintColor:[UIColor redColor]];
You can do this in you - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions , for example.
In the previous version of iOS you should make a Category on NavigationBar, and override it's drawing methods.
When you create your Navigation Controller, you can set the color for the bar:
navigationController = [[UINavigationController alloc] initWithRootViewController: mainView];
self.navigationController.navigationBar.tintColor = [UIColor <whatever color you want>];
Or if you just want the default blue color:
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
You're doing it the right way. The navigation bar can be shared between many ViewControllers when pushViewController has been used (e.g. when showing a detail view for an item in an UITableViewController).
iOS5 has a new UIAppearance feature for more detailed app-wide themeing that you might want to check out - http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5
To set the default color, use:
[[UINavigationBar appearance]setTintColor:nil];
To set a different color with gradient, use:
[[UINavigationBar appearance]setTintColor:[UIColor colorWithHue:hue/359.0f
saturation:saturation/100.0f
brightness:brightness/100.0f
alpha:alpha]];
Please note; hue, saturation, brightness and alpha are of type float.

Resources