This question already has answers here:
Override UIAppearance property for MFMailComposeViewController
(3 answers)
Closed 9 years ago.
I am setting the appearance protocol to add a custom image for all my navigation bars. This is working as expected, but I do not want to change the appearance for the
MFMailComposeViewController's navigation bar.
How can I make this navigation bar, the default navigation bar?
[[UINavigationBar appearance] setBackgroundImage:[ApplicationStyle navigationBarImage] forBarMetrics:UIBarMetricsDefault];
The appearance proxy enables you to modify the appearance of the UI when it's contained in a specific class through the -appearanceWhenContainedIn method. You can set the image to nil to prevent it from being shown in the MFMailComposeViewController class as shown below.
[[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
According to this question, you need to change the appearance proxy before and after you present the modal MFMailComposeViewController in order to change its appearance back to how it was.
Override UIAppearance property for MFMailComposeViewController
Related
I can hide or unhide tab bar in navigation controller. But issue when I use presentModelViewController of MPMediapickercontroller, and even when hiding custom tab bar, it overlaps the tab bar of MPMediapickercontroller.
Please take a look at this image.
This is a default 'MPMediapickercontroller' presented.
I have been surfing to find this fix but with no success.
In MPMediapickercontroller its always present modally. so one solution for that is you have to use image which is same as tabbar of MPMediapickercontroller.
Here is that image. use without any border just white image thats it.
Now, below is my code.
In Viewwillappear method you have to set that image in tabbar appearance.
-(void)viewWillAppear:(BOOL)animated
{
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:#"tabDefault"]];
[super viewWillAppear:YES];
}
Then whatever you want presentModelViewController of MPMediapickercontroller
in last you done all things then you have to use dealloc method to set Tabbar same as you required permanent.
-(void)dealloc
{
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:#"tab2"]];
}
I solved my problem from this. hope you done it.
This question already has answers here:
iPhone: Setting Navigation Bar Title
(13 answers)
Setting title of UINavigationBar
(3 answers)
Closed 10 years ago.
in my app i'm am basically pushing a viewcontroller from another one
[self.navigationController pushViewController:vc animated:YES];
The view controller that results from this call has a navigation bar but I can't name it through the story board. Basically, how do I set the navigation bar's text in code?
add this line to viewDidLoad
self.navigationItem.title = #"MyTitle";
If you are working in the storyboard then you can also set the title of the navigationBar just double clicking on the navigationBar. I will work fine for you. try that.
I'm using iOS's UIAppearanceProxy to customize the look of my app.
In most of the app, I want the navBar to have one background image. In one specific section of the app, I want the navBar to have a different background image.
Here's what I'm doing in application:didFinishLaunchingWithOptions:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navbar_bg1"]
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearanceWhenContainedIn:[DiscoverViewController class], nil] setBackgroundImage:[UIImage imageNamed:#"navbar_bg2"] forBarMetrics:UIBarMetricsDefault];
I would like to keep all my appearance code in one place instead of overriding the navBar in a specific view controller.
Also helpful to know is that my app is structured with a TabBarController, where each tab controls a NavigationController which owns a subclassed ViewController, like DiscoverViewController above.
What am I doing wrong?
As you just stated, the navigation bar is not contained in the DiscoverViewController in your hierarchy; rather, both are contained in a navigation controller. One way to keep the appearance code centralized is to create an empty subclass of UINavigationController and instantiate that instead of UINavigationController in the relevant place (whether that's a nib or storyboard or just programmatically). Then, to style child elements, get their appearance proxy "when contained in" DiscoveryNavigationController or what have you. I've used this method with good results in the past.
I customized the appearance of all my navigation bars by using the UIAppearance API introduced in iOS 5:
[[UINavigationBar appearance] setTitleTextAttributes:titleTextAttributes];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:+2.f forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setTintColor:[UIColor lightTextColor]];
This works great for all my own navigation bars.
However, it also styles all system-provided navigation bars, such as when I modally display an MFMailComposeViewController (see screenshot below) or use the ABPeoplePicker.
Is it possible to define exceptions such as “don’t use this appearance when shown modally”?
take a look at appearanceWhenContainedIn option, this allows you to select which viewcontroller class the appearance applies to
I have multiple tabs (more than 5) in the tab bar in my app, and when this happens, xcode automatically makes the last tab a "more" tab and puts the last tabs in it. The problem is, I have navigation bars in the other tabs that are a different color than any of the default colors, and the automatically generated "more" tab is the default blue color. I was wondering if there was any way to change this?
Thanks a lot
Sam
tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
or
tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor orangeColor];
See this answer for customizing the navigation bar colour of the "edit" modal view controller: Link
This reads to me like you actually want to change the color of a selected tabbaritem. If so, then this post has myriad solutions: Custom colors in UITabBar
Otherwise, if you mean what you write in the title, you can change the color of a navigation bar by changing the tintColor property.
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackOpaque];
place this in the AppDelegate under - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions