How to customize UINavigationBar in IOS5 - ios

In IOS5, I do not yet know how to customize UINavigationBar.
My code is like this:
[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithWhite:0.5f alpha:1.0]];
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor blackColor],UITextAttributeTextColor
,[UIColor blackColor], UITextAttributeTextShadowColor
,[NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset
,[UIFont fontWithName:#"Arial" size:20.0],UITextAttributeFont
, nil]];
// Customize UIBarButtonItems
UIImage *gradientImage44 = [[UIImage imageNamed: #"title__bg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:gradientImage44 forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor
,[UIColor whiteColor], UITextAttributeTextShadowColor
,[NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset
,[UIFont fontWithName:#"Arial" size:14.0],UITextAttributeFont
, nil] forState:UIControlStateNormal];
// Customize back button items differently
UIImage *buttonBack30 = [[UIImage imageNamed:#"bn_back"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack30 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
This pic is UINavigationViewController used in PopoverView.
This pic is UINavigationViewController opened by Modal.
As you see, I set background-image, nevertheless NavigationBar's border is different.
Is this a problem about PopoverView?
I do not know What I'd missed.
Please tell me your advice. Thanks!!! and Happy new year!!!

Goto AppDelegate.m and paste the code under
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Set the status bar to black color.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque
animated:NO];
Change #"menubar.png" to the file name of your image.
UIImage *navBar = [UIImage imageNamed:#"menubar.png"];
[[UINavigationBar appearance] setBackgroundImage:navBar
forBarMetrics:UIBarMetricsDefault];

Have a look at this: UINavigationBar Apple developer reference

Related

iOS PopoVer NavigationBar don't show BarTintColor

In our app we're setting the navigationbar and toolbar color with the following code. With iOS 8.x this is working fine. Recently I have tested the app with iOS 7.x and the colors aren't shown. The bars are transparent and the text has white color (so this worked...)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0/255.0 green:167.0/255.0 blue:0.0/255.0 alpha:1.0]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UIToolbar appearance] setBarTintColor:[UIColor colorWithRed:255.0/255.0 green:167.0/255.0 blue:0.0/255.0 alpha:1.0]];
[[UIToolbar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset,
[UIFont boldSystemFontOfSize:19.0], NSFontAttributeName,
nil]];
I hope somebody could explain me how to solve this. Setting the bars background color is no solution to me because i would use transparency.
The solution to this issue is to set the color-values manually in the popping-up ViewController again for iOS 7.
self.navigationController.toolbar.barStyle = UIBarStyleBlackTranslucent;
[self.navigationController.toolbar setTintColor:[UIColor whiteColor]];
[self.navigationController.toolbar setBarTintColor:[UIColor colorWithRed:255.0/255.0 green:167.0/255.0 blue:0.0/255.0 alpha:1.0]];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:255.0/255.0 green:167.0/255.0 blue:0.0/255.0 alpha:1.0]];

iOS 7 UINavigationBar appearance not working first timeā€¦

I am trying to change the look of the UINavigationBar in my iOS7 app. I am doing the following:
- (void)viewDidLoad
{
[super viewDidLoad];
m_sNumberToCall = #"";
UIBarButtonItem * btn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"IconHome.png"] style:UIBarButtonItemStyleBordered target:self action:#selector(btHomeTouched:)];
self.navigationItem.leftBarButtonItem = btn;
self.navigationController.navigationBar.translucent = YES;
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"TVCNavBack.png"] forBarMetrics:UIBarMetricsDefault];
NSShadow * shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0],
NSForegroundColorAttributeName,
shadow,
NSShadowAttributeName,
[UIFont fontWithName:#"Helvetica-Bold" size:21.0],
NSFontAttributeName,
nil]];
}
But, the first time I present the UITableViewController it is the standard iOS7 nav bar, then I press home and present it again and it is my new look.
Any ideas why it does not work the first time?
Don't change the appearance but the navigation bar directly. The appearance affects only the future instances but not the already created ones.
Change:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"TVCNavBack.png"] forBarMetrics:UIBarMetricsDefault];
to:
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"TVCNavBack.png"] forBarMetrics:UIBarMetricsDefault];
The answer before only helps you with the background image but not with the title text attributes.
You don't need to change your code but all you have to do is move it to
applicationDidFinishLaunchingWithOptions
in your AppDelegate.m file.

Apply a Global conditional format to UISearchBar, UINavigationController, UIToolbar in iOS

I'm applying next global format to my app:
-(void)customizeAppearance{
//Customizing UINavigationBar
UIImage *navigationbarImage44 = [[UIImage imageNamed:#"navigationbar_44"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
UIImage *navigationbarImage32 = [[UIImage imageNamed:#"navigationbar_32"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
//Set the background image for *all* UINavigationBars
[[UINavigationBar appearance] setBackgroundImage:navigationbarImage44 forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:navigationbarImage32 forBarMetrics:UIBarMetricsLandscapePhone];
//Customize the titlebar for *all* the navigationBars
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:labelFontName size:0.0], UITextAttributeFont,
nil]];
//Customizing UIToolbar
UIImage *toolbarImage44 = [[UIImage imageNamed:#"toolbar_44"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
UIImage *toolbarImage32 = [[UIImage imageNamed:#"toolbar_32"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UIToolbar appearance] setBackgroundImage:toolbarImage44 forToolbarPosition:UIToolbarPositionAny
barMetrics:UIBarMetricsDefault];
[[UIToolbar appearance] setBackgroundImage:toolbarImage32 forToolbarPosition:UIToolbarPositionAny
barMetrics:UIBarMetricsLandscapePhone];
//Customizing UIBarButtonItem
UIImage *button30 = [[UIImage imageNamed:#"buttonitem_30"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
UIImage *button24 = [[UIImage imageNamed:#"buttonitem_24"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
[[UIBarButtonItem appearance] setBackgroundImage:button30 forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundImage:button24 forState:UIControlStateNormal
barMetrics:UIBarMetricsLandscapePhone];
//Customizing UIBarButtonItem BackButton
[[UIBarButtonItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:labelFontName size:0.0], UITextAttributeFont,
nil]forState:UIControlStateNormal];
UIImage *buttonBack30 = [[UIImage imageNamed:#"backbuttonitem_30"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)];
UIImage *buttonBack24 = [[UIImage imageNamed:#"backbuttonitem_24"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 5)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack30
forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack24
forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
//Customizing UISegmentedControl
[[UISegmentedControl appearance] setTintColor:(UIColorFromRGB(toolbarTintColor))];
//Customizing UISearchBar
[[UISearchBar appearance] setBackgroundImage:navigationbarImage44];
}
and I'm calling this at my AppDelegate.m method
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self customizeAppearance];
return YES;
}
The question is:
How do I condition all this general format if the viewController is not inside an iPad popup???
I don't want my popups to share original format, I want them with UINavigationBars, UIToolbars, UIBarButtonItems.. in black color as always
thanks in advance for the support
Instead of using appearance you can use appearanceWhenContainedIn:. So instead of
[[UINavigationBar appearance] setBackgroundImage:navigationbarImage44 forBarMetrics:UIBarMetricsDefault];
do
[[UINavigationBar appearanceWhenContainedIn:[CustomViewController class]] setBackgroundImage:navigationbarImage44 forBarMetrics:UIBarMetricsDefault];
which will restrict the appearance changes to only UINavigationBar instances contained in CustomViewController. You may want to check out this question for clarification on how to use appearanceWhenContainedIn for things like UIBarButtonItem.

Change single navigation bar color for total app

I have using two UINavigationBar's in my app ,now am applying themes to my app i'm trying to change navigation bar color of the total app using this line of code
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
am getting two navigation bars with black color is there any way to change single navigation bar color for total app
Instead of [UINavigationBar appearance] you can use [UINavigationBar appearanceWhenContainedIn:...] to be more specific about which UINavigationBars are changed based on their context.
For example you could create a subclass of UINavigationController called MyNavigationController (no need to add any behaviour) then do:
[[UINavigationBar appearanceWhenContainedIn:[MyNavigationController class], nil] setTintColor:[UIColor blackColor]];
Only UINavigationBars that live within your subclass will have their appearance changed.
I've used this idea in an iPad app where I wanted UINavigationBars that appeared within modal FormSheets to look different to other UINavigationBars within the app for example.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if(isiPhone5)
{
self.LoadinFirst = [[LoadingFirstViewController alloc] initWithNibName:#"LoadingFirstView-iPhone5" bundle:nil];
}
else {
self.LoadinFirst = [[LoadingFirstViewController alloc] initWithNibName:#"LoadingFirstView" bundle:nil];
}
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.LoadinFirst];
[navigationController.navigationBar setBarStyle:UIBarStyleBlack];
[navigationController.navigationBar setTintColor:[UIColor colorWithRed:192/255.00f green:182/255.00f blue:184/255.00f alpha:1.0f]];
self.window.rootViewController =navigationController;
[self.window makeKeyAndVisible];
return YES;
}
If you want to put an image in the navigation bar with the color you want you can use
if ([self.navigationController.navigationBar respondsToSelector:#selector(setBackgroundImage:forBarMetrics:)] )
{
UIImage *image = [UIImage imageNamed:#"titlebg.png"] ;
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
else you can easilt set the tint by using
[navigationController.navigationBar setTintColor:[UIColor colorWithRed:102/255.00f green:182/255.00f blue:114/255.00f alpha:1.0f]];
hope this helps.
To change the over all navigation bar color you can use the method
[[UINavigationBar appearance] setBackgroundColor:[UIColor blueColor]];
To change the overall font and such you can use something like :
-(void) changeNavigationBarStyle{
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
UITextAttributeTextColor,
[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f],
UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:#"ChalkboardSE-Bold" size:0.0],
UITextAttributeFont,
nil]];
NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithDictionary: [[UIBarButtonItem appearance] titleTextAttributesForState:UIControlStateNormal]];
[attributes setValue:[UIFont fontWithName:#"ChalkboardSE-Bold" size:0.0f] forKey:UITextAttributeFont];
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];
}
EDIT DUE TO COMMENTS
To change the color (blue in this example) of all UINavigationBars in the application you can call
[[UINavigationBar appearance] setBackgroundColor:[UIColor blueColor]];
To change the color of one UINavigationBar you can call
self.navigationController.navigationBar.tintColor = [UIColor blueColor];
There is no middle ground where you can say "Change all UINavigationBar's color except ..."

xcode - Design / Redesign MailController / MFMailComposeViewController

Is it possible to Redesign the MFMailComposeViewController?
How?
The App Dropbox can do it.
Picture: http://jonathangurebo.tumblr.com/post/40436277822
Can I change the "MessageUI.framework"?
To answer your request regarding customizing the appearance of ALL navigation bars in the app, use this in your application:didFinishLaunchingWithOptions: in your app delegate:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"image"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTintColor:[UIColor blueColor]];
[[UINavigationBar appearance] setAlpha:1];
//change background image and tint color for navigation buttons
// Set the text appearance for navbar
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:2 forBarMetrics:UIBarMetricsDefault]; //change vertical appearance of navigation bar title
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(1, 1)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:#"HelveticaNeue" size:22], UITextAttributeFont,
nil]]; //set custom font info

Resources