How put navigationBar backgroundImage without opacity in ios 7? - ios

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

Related

iOS 8 how make navigationBar transparent even rotate

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/

Use of "UINavigationBar appearance setTranslucent:NO" in iOS 7

I am Defining My UINavigationBar color code in AppDelegate with:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0f/255.0f green:87.0f/255.0f blue:10.0f/255.0f alpha:1]];
Then I also set the Translucent of my NavigationBar with:
[[UINavigationBar appearance] setTranslucent:NO];
My Project's Deployment target is iOS 7 & Target SKD iOS 8. The project got crash only when I run it on any iOS 7 device. After digging a little, I found that [[UINavigationBar appearance] setTranslucent:NO]; is not worked in iOS 7. So I want to know "Except calling it locally (in every viewController)" is there any way to use it for iOS 7 to iOS8?
Thanks a lot in advance.
You can achieve this by using a non exist image that makes fool of compiler like:-
[[UIToolbar appearance] setBackgroundImage:[[UIImage alloc] init] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
instead of:
[[UINavigationBar appearance] setTranslucent:NO];

xcode remove custom navigation image in pickerview galley

I added the following code in the appDelegate to achieve custom background images for the navigation bar.
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"Nav-Bar_01.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"Nav-Bar_02_alter.png"] forBarMetrics:UIBarMetricsDefaultPrompt];
However, I want to exclude the native gallery pickerView from this background.
Is there any way to do so without applying the background on each navigation bar alone, but keeping the same code in the appDelegate ?
I ended up placing a background image for every navigation controller instead of placing it in the App Delegate. The background was then not applied on the pickerView.
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"Nav-Bar_01"] forBarMetrics:UIBarMetricsDefault];

iOS 7.1 UINavigationbar and UIToolbar

After upgrading Xcode in iOS7.1 my navigation bar and UIToolbar buttons are not shown with correct colour.
When a view first appears the UIToolbar buttons all have the correct default blue colour and when I go to next page/view and come back to the previous view the toolbar buttons are shown in a grey colour.
I have tried to add the blue colour in viewDidLoad and viewWillAppear but no luck. Can someone please help me?
Thanks.
You can set up a theme for certain components all at once and they will be used throughout your application. In my app delegate I created a function when the application is initializing called setupTheme, and it does just that - sets up the "theme" of the application by saying things like [[UINavigationBar appearance] setBarTintColor:], which in effect sets the color of the navigation bar for ANY navigation controller throughout the app. Here's an example from an app that sets up some basic components that are reused so that any time you use them they will already have the correct theme applied.
- (void)setupTheme {
// get our theme colors
UIColor *primaryThemeColor = [UIColor blueColor];
UIColor *secondaryThemeColor = [UIColor whiteColor];
// nav bar
[[UINavigationBar appearance] setBarTintColor:primaryThemeColor];
[[UINavigationBar appearance] setTintColor:secondaryThemeColor];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName:secondaryThemeColor}];
// tab bar
[[UITabBar appearance] setTintColor:primaryThemeColor];
// switches
[[UISwitch appearance] setOnTintColor:primaryThemeColor];
// search bar
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal];
}
Check out the iOS 7 transition guide for more details on specifics https://developer.apple.com/library/iOs/documentation/UserExperience/Conceptual/TransitionGuide/Bars.html#//apple_ref/doc/uid/TP40013174-CH8-SW1

UINavigationController background color changes that hide Back Button in iOS

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"]];

Resources