When I set NavigationBar to translucent, I expect that the NavigationBar will not has a shadow line under it, and StatusBar has the same background of the view's background
I code like this:
[self.navigationController.navigationBar setTranslucent:YES];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"translucent_image"] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
They work perfectly on 5.5 inch iPhone like iPhone6 Plus and iPhone 6s Plus, But when run on the smaller iPhones like iPhone 6s and iPhone 5s, I get a bug like problem, The StatusBar turn into black! They are the same code on iOS 8.2, iOS 8.3 and iOS 9.2, The only difference is the screen!
I try to change the BarMetrics from UIBarMetricsDefault to UIBarMetricsCompact or UIBarMetricsDefaultPrompt to fix this problem, finally the StatusBar work well but the shadow line come out in all iPhones!
[self.navigationController.navigationBar setTranslucent:YES];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"translucent_image"] forBarMetrics: UIBarMetricsCompact];
self.navigationController.navigationBar.shadowImage = [UIImage new];
so strange! is this a bug of iOS?
Try changing your code to
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];
This works for me (i.e. I don't get the shadow)
Related
I am facing issue in margin of right bar button item title.
From iOS11 background image is overlapped means it is not properly right aligned.
It was working pretty good till iOS 10.
Code snippet:
UIBarButtonItem *rightItem = self.navigationItem.rightBarButtonItem;
[rightItem setBackgroundImage:[UIImage imageNamed:IMAGE_NAVIGATION_NEXT_BUTTON_DISABLED_iOS7]
forState:UIControlStateDisabled
barMetrics:UIBarMetricsDefault];
[rightItem setBackgroundImage:[UIImage imageNamed:IMAGE_NAVIGATION_NEXT_BUTTON_iOS7]
forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
rightItem.title = #"Next";
Before iOS11 it was working like this
before today, i think it is so easy to make navigationBar transparent.
but i stuck here also 3 hours...
here is my problem,
I want my navigationBar transparent, but navigationItem not.
but when i rotate my screen, it appear like
i tried to set my navigationBar background clear;
[self.navigationController.navigationBar
setBackgroundImage:[UIImage imageNamed:#"navibg"]
forBarMetrics:UIBarMetricsCompact];
tried
self.navigationController.view.backgroundColor =
[UIColor clearColor];
tried
self.navigationController.navigationBar.shadowImage =
[UIImage imageNamed:#"navibg"];
tried
[[UINavigationBar appearance]
setBackgroundImage:[UIImage imageNamed:#"navibg"]
forBarMetrics:UIBarMetricsCompact];
And i use xcode 7.2.
in your apps plist file add a row call it "View controller-based status bar appearance" and set it make sure it set to Yes and let me know its working or not for customization help pls check http://www.appcoda.com/customize-navigation-status-bar-ios-7/
Hi I have navigationBar with image in ios 7 [xcode 5].
When I run my application my navigationBar auto be blur.
I want to chenge it to regular [no blur].
my code:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"nav_bg.png"] forBarMetrics:UIBarMetricsDefault];
I try add this code but the apps crash:
[[UINavigationBar appearance] setTranslucent:NO];
What need I do to make all my navigation bars in app to regular?
thank
If you are using storyboard you can set it here
If you need to set it in code use
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
in your viewDidLoad
I try to set background image to navigationBar I use blow code
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"pp_Header.png"] forBarMetrics:UIBarMetricsDefault];
My image height is 120px
In iOS6 navigationBar height 120px but in iOS7 shows only 68px but i need to show 120px,
similarly Tool bar also having same problem
[pad_por_Toolbar setBackgroundImage:[UIImage imageNamed:#"Logo_bottom.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
how to solve this ?
i have made a simple design in photoshop
when i tried to put it in Xcode i had some problems with NavigationBar
i used this code to change the UINavigationBar background image (a PNG transparent image):
UINavigationBar *navBar = [[self navigationController]navigationBar];
[navBar setBackgroundImage[UIImageimageNamed:#"navBar2.png"]forBarMetrics:UIBarMetricsDefault]
everything works fine but the problem is that the image appears in the navigationBar without transparency.
please someone help me to fix the transparency issue i search everywhere without any satisfied answer
NB! Im using IOS 5
You might try setting the navigation bar to translucent.
[navBar setTranslucent: YES];
Do you have it in your Storyboard? Try change the style of your navigation bar into black translucent.
What you can do is set the background color of the view of the navigationController the same as the backgrouond color of the main view.
//Set your view's background color
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"view_background"]]];
//Set your custom image for the navigationController
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed: #"navigation_bar_image"] forBarMetrics:UIBarMetricsDefault];
//And then set the background color of the navigationController the same as the one of the view
[self.navigationController.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"view_background"]]];
[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationBar setShadowImage:[UIImage new]];
[self.navigationBar setTranslucent:YES];
And make sure you set up tint color to default.