Yomo
Yomo

Reputation: 175

Change navigation bar color/font to default when sending email, text message, etc (Objective-C)

For changing navigation bar color and text font/color I use this code in the AppDelegate.m:

//Bar color.
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0xe58509)];

//Bar text.
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
shadow.shadowOffset = CGSizeMake(0, 0);
[[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:@"Heiti SC" size:20.0], NSFontAttributeName, nil]];

It works perfectly, but the problem is that when the user sends an email or text message the navigation bar color and text font/color are the same which I don't want. I want to set everything to default color and font when sending an email or text message. Any ideas?

Thanks!

Upvotes: 0

Views: 271

Answers (1)

Yomo
Yomo

Reputation: 175

Well, I've figured out a workaround. Everytime I need to change everything to default, I set them to nil like this:

[[UINavigationBar appearance] setTintColor:nil];
[[UINavigationBar appearance] setBarTintColor:nil];
[[UINavigationBar appearance] setTitleTextAttributes:nil];

In this case in the IBAction for sending an email e.g.

And when the email or text message is sent, I set everything back with the same code displayed in the question.

Upvotes: 1

Related Questions