Hash88
Hash88

Reputation: 712

iOS navigation bar functions correctly, but is wrong color

Here's my problem: I have a navigation bar at the top of a UINavigationController. I have it set to disable and re-enable when certain popovers are onscreen. One case isn't working: when a Dropbox popover comes on screen the bar disables as it should. But when I close the popover (press cancel) the navigation bar re-enables as it should, but it stays grayed-out as long as the app is open, though it functions correctly. It should return to blue at this point. It does turn blue when I close other popovers. Just the Dropbox one is giving me problems. I don't see any kind of "Highlighted" attribute for the NavBar, and I'm switching the UserInteractionEnabled attribute correctly. Any ideas?

Upvotes: 1

Views: 1159

Answers (2)

Madhu
Madhu

Reputation: 1542

// This is for iOS 7.0 or more than that.

   if ([self.navigationController.navigationBar respondsToSelector:@selector(setBarTintColor:)]) {
    self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
} else {
    [self.navigationController.navigationBar setTintColor:[UIColor blueColor]];
}

 //  For text alignments 

    [[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:1.0 green:1.0 blue:1.0 alpha:1.0],
      UITextAttributeTextShadowColor,
      [NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
      UITextAttributeTextShadowOffset,
      [UIFont fontWithName:@"Helvetica-Bold" size:20.0],//[UIFont fontWithName:@"DynoBold" size:20.0],
      UITextAttributeFont,
      nil]];

Upvotes: 1

Harunmughal
Harunmughal

Reputation: 367

Put this code at the cancel action of popover.

You can use this one for ios7

[self.navigationController.navigationBar setBarTintColor:[UIColor blueColor]];

This one for the ios6

[self.navigationController.navigationBar setTintColor:[UIColor blueColor]];

Thanks

Upvotes: 1

Related Questions