Hi i'm working on an iOS project that uses the MFMailComposeViewController to send out an email.
I changed the title bar to use an image
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"project_headerbg"] forBarMetrics:UIBarMetricsDefault];
but now when I click on the '+' button next to CC I can't read the text "Choose a contact to mail" in the header very well and was wondering if there was a way to change the color of that text?
Thanks
This question has nothing to do with using the MFMailComposeViewController. If you wish to customize the appearance of a UINavigationBar, then you may need to set more properties than just the background image. You should also setup the titleTextAttributes.
// Use whatever color is appropriate
NSDictionary *attributes = #{ UITextAttributeTextColor: [UIColor blueColor] };
[[UINavigationBar appearance] setTitleTextAttributes:attributes];
There are other attributes such as the font and shadow colors. Feel free to set the ones you need.
Related
I am able to change tho color of NavigationBar by giving BackgroundColor but than I am not able change the color of StatusBar. Please provide a solution.
You should change the barTintColor instead of the background color.
[self.navigationController setBarTintColor:[UIColor redNavigationBarColor]];
Chances are that you will probably need to change also the barButton color and/or the the title color and all that should probably apply to more than one screen. So, to save you some time, if you want to globally change all these, put the code below in your app delegate
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
The code above will give you a red navigation bar with white title & buttons
I'm trying to set the colour of the cancel buttonBarItem to white on the Message / Mail activityItems presented with the UIActivityViewController but whatever I do it doesn't change them.
The cancel remains the standard default blue used in iOS7 as do other items in these views that ideally I would like to change. I've tried using the code below in the AppDelegate which sets the colour correctly throughout the rest of the app but it doesn't work when these views are presented.
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
These settings do retain their values when added to AppDelegate and these views are presented as can be seen below.
[[UINavigationBar appearance] setBarTintColor:SOLIDTEALCOLOR];
[[UINavigationBar appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName: [UIColor whiteColor]}];
Do I need to roll my own ActivityViewController using bespoke SLComposeViewControllers for each activityItem to have this degree of control this colour? It seem like an unnecessary large amount of work for something that really shouldn't be an issue.
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
I am trying to find out how to change the text and arrow color of the UINavigationBar buttons.
I know how to change the titleTextAttributes but cannot find out how to do it to the buttons.
For example this is how I change the titleTextAttributes inside my AppDelegate
self.navigationController.navigationBar.titleTextAttributes = #{NSForegroundColorAttributeName : [UIColor redColor]};
I have looked through the UINavigationBar docs and cannot find any button attributes so not sure what to do here.
to change the text color and the color of the arrow in the navigation bar you can use this code (iOS 7):
self.navigationController.navigationBar.tintColor = [UIColor redColor];
this code will also change the color of the buttons
You can globally change it as easy as this
I have a pop up window that slides on screen when a certain button is pressed.
This view has a custom look apart from the rest of the app. It has an .xib file as well. I have managed to change the header background color by adding a customClass to the toolbar in IB. I have managed to change the text style of the title text... It took me some time to figure that out. What I had to do was make an IBOutlet from the title item in IB, then apply the changes in my m...like so
- (void)customizeAppearance
{
//Sets custom text attribures for this views headers text
[_customNavText setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor, //sets text color
[UIColor blackColor], UITextAttributeTextShadowColor, //sets text shadow color
[NSValue valueWithUIOffset:UIOffsetMake(0, 3)], UITextAttributeTextShadowOffset, //Moves drop shadow by its coordinates
[UIFont fontWithName:#"Helvetica-Bold" size:27.0], UITextAttributeFont,nil] //sets text font and size
forState:UIControlStateNormal];
}
and this function gets called once the view loads. So my text has its own style on this view only. Great.
So, maybe I am getting to picky, but now I want to move the text down a couple pixels.
This is what I did, I added the following code inside the customizeApperance function...
[[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(25.0f, 25.0f) forBarMetrics:UIBarMetricsDefault];
But this does something interesting, it does not move my text down for the UIBarButtonItem I have just applied those styles too, instead it moves the text of the buttons on the nav bar, such as the cancel button.
So how do I move the UIBarButtonItem thats in the middle, containing text for the navigation header, rather than the text of the buttons on the side?
I think you might be looking for:
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:1 forBarMetrics:UIBarMetricsDefault];