Reputation: 4136
Let me explain my situation first. I set the UINavigationBar
color in my appDelegate
Like:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0f/255.0f green:87.0f/255.0f blue:10.0f/255.0f alpha:1]];
Now in my some viewController
the translucent
of UINavigationBar
set as YES
.
self.navigationController.navigationBar.translucent = YES;
That's why there is a shade over my UINavigationBar
. It wasn't showing the exact color. As a solution, I set translucent
from YES
to NO
. It is showing the exact color now, But I am facing that some of my view completely gone from my interface. Here, let me tell you one thing that, so many of views here, is positioned by programmatically, so I am afraid I can't just move every of my viewController
s view 64 px high. Just wondering is there any solution to solve the thing. I try with opaque
, but no luck. If any one understand my problem please share the solution if you have. Thanks a lot in advance.
Upvotes: 0
Views: 770
Reputation: 769
Its late, but i face same issue, and i resolved it by making UINavigationbar none on Viewcontroller in storyboard, and resized the view to start from 0,0
Upvotes: 0
Reputation: 26383
From iOS7 if you use a translucent bar ( in UINavigationController
or UITabbarController
) the hosted view controller has as default behavior to extend under them. If you say to set the bar as translucent the color of it it will be a combination of the view under it and bat color. That is normal and the only way is to set translucency to no or apply a background image to navigation bar.
Applying frames manually will lead to unexpected result under auto layout, you must use constraints.
[UPDATE]
To create a background image from a solid color you can use that method, the image is 1px square, but there is no problem because it can be stretched or tiled to cover the entire area:
+ (UIImage *) imageWithColor:(UIColor*) color {
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *colorImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return colorImage;
}
If you see and extra gap is probably because you have also set automaticallyAdjustScrollViewInset to YES, try setting it NO. This property add and extra inset to your view or your vfirst view subview if it inherits from a UIScrollView
Upvotes: 1