1

I have a reference of UIViewController. From that reference i want to get references to all my navigation bar and bar button items and apply custom styles on them.

How can i achieve this on iOS 5?

orak
  • 2,399
  • 7
  • 29
  • 55

2 Answers2

1

You can do something like that.

[backbutton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                   [UIColor blackColor],UITextAttributeTextColor,[UIFont fontWithName:TEXTFONT size:16.0f],UITextAttributeFont,
                                                   nil] forState:UIControlStateNormal];
alper_k
  • 512
  • 1
  • 6
  • 18
  • how do i fetch backbutton from UIViewController reference? – orak Dec 12 '12 at 10:16
  • backbutton is just the name of UIBarButtonItem. You can name it whatever you want. UIBarButtonItem *backbutton = [[UIBarButtonItem alloc] init]; That's what I'm trying to say. – alper_k Dec 12 '12 at 10:26
  • i don't have a reference to backbutton. i want to fetch it from viewcontroller reference – orak Dec 12 '12 at 10:41
0

Assuming your view controller has a navigation controller, you should be able to access the navigation bar and its items using the following code:

UINavigationBar *navBar = [myViewController.navigationController.navigationBar];
NSArray *navBarItems = navBar.items;
Tarek
  • 2,372
  • 2
  • 23
  • 35
  • and how would i change the font for the back bar button item? – orak Dec 12 '12 at 08:02
  • Check out this post: http://stackoverflow.com/questions/10040699/change-font-of-back-button-on-uinavigationcontroller – Tarek Dec 12 '12 at 08:15