How to change the UInavigationbar background color without image | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

How to change the UInavigationbar background color without image

Tuesday

UInavigationbar with custom color(Set different colors for both UInavigationbar and UIBarButtonItem):
                                                      The following code which is used to programmatically  set color  for UInavigationbar. Here I'm changed the UInavigationbar color and also button color, without use any images.
Here we can set different colors for both UInavigationbar and UIBarButtonItem.

UInavigationBar Color - Codingcluster
         
Code:
- (void)viewDidLoad
{  
    self.title = @"Coding Cluster"; 
    // use setNavigationBarHidden:animated: if you need animation 
    self.navigationController.navigationBarHidden = NO;
   
     UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
                                  initWithTitle:NSLocalizedString(@"Click Me", @"")
                                  style:UIBarButtonItemStyleDone
                                  target:self
                                  action:@selector(YourActionMethod:)];
   
    self.navigationItem.rightBarButtonItem = addButton;
    UIColor *barColor = [UIColor colorWithRed:136/255.0f green:111/255.0f blue:172/255.0f alpha:1/255.0f];
    UIColor *buttonColor = [UIColor colorWithRed:157/255.0f green:136/255.0f blue:187/255.0f alpha:0.50/255.0f];
    UINavigationBar *bar = [[self navigationController] navigationBar];
    [bar setTintColor:barColor];
    [addButton setTintColor:buttonColor];
      } 

That's all. If this post is useful for you , please share this knowledge to your friends. Thanks!

1 comments:

Anonymous said...

Your code helped me a lot.Thank You sooo much..

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets