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.
Related
I'm using Objective-C. Here I need to change the background color of an UINavigationBar. And I tried this code below:
self.navigationController.navigationBar.backgroundColor = [UIColor greenColor];
But the result is:
What I want is change the color of the NavigationBar into the green color below instead of a blurry green as it is now. Someone please help me.
do like select your Naigation Bar on storyboard and change the property of bar tint in directly in inspector
Just add this code
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
Try to use appearance
[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];
Hope this help
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/
I am trying to change Navigation bar background color in viewDidLoad using the same example in the link below but that's not working.
[[UINavigationBar appearance] setBackgroundColor:[UIColor greenColor]];
please help.
https://github.com/aryaxt/iOS-Slide-Menu
To change the NAv bar color, You have to use bar tint color:
self.navigationController.navigationBar.barTintColor=[UIColor greenColor];
Currently, I am able to change the tint of the my UINavigationBar by
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:74/255.0f green:74/255.0f blue:74/255.0f alpha:1.0f];
However when I try to implement the following code to change the image of the UINavigationBar all together, I see no results..
UIImage *navImageBackground = [[UIImage imageNamed:#"texturedNav"] //This being my .png image
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:navImageBackground
forBarMetrics:UIBarMetricsDefault];
What am I doing wrong here?
You're probably calling the appearance delegate after the navigation bar is already on screen so your request is being 'ignored'. Or, at least, not causing a UI update.
Set the appearance before the navigation bar is shown. Or, force a UI refresh by hiding and showing the navigation bar (without animation).
Now I am trying to change UINavigationController background image with my custom Image.
I can change with following codes.
[navigation.navigationBar insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"navController.png"]] atIndex:1];
So I got following pic. That pic is right and show the BarButton.
But when I go to the detailViewController , there is no BackButton. However I can tap without seeing it.
After I back to MainViewController , my UINavigationController Background is happening like following pic.
They are hiding my button. I'm thinking atIndex:1 is making this problem because Index 1 is above 0 and All button Index must be 0.
That's why all buttons are disappearing.
So how can I solve that problem? Please help.
Thanks for your help.
// not supported on iOS4
UINavigationBar *navBar = [purchaseNavController navigationBar];
if ([navBar respondsToSelector:#selector(setBackgroundImage:forBarMetrics:)])
{
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"brnlthr_nav.jpg"] forBarMetrics:UIBarMetricsDefault];
}
Try using the appearance proxy provided by apple
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"your_image"] forBarMetrics:UIBarMetricsDefault];
that will set it for the entire application or you can use
[[self.navigationController.navigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"your_image"]];