2

I have a small question...How to search through the sub views of navigation bar ? How can I get subviews of navigation bar ?

Maulik
  • 19,348
  • 14
  • 82
  • 137
SURESH SANKE
  • 1,653
  • 17
  • 34

2 Answers2

4

If I understood your question properly then You can do this :

for (UIView *temp in self.navigationController.navigationBar.subviews)
{        
    if ([temp isKindOfClass:[UIButton class]]) 
    {
        NSLog(@"is button !");

        UIButton *tempButton = (UIButton *)temp ;
    }
    else if ([temp isKindOfClass:[UILabel class]])
    {

    }
}
Maulik
  • 19,348
  • 14
  • 82
  • 137
0

You don't have to search through the navigation bar's subviews to change attributes of the title label. You can access the titleView of a viewcontroller's navigationItem and set it to a label you created with a custom font.

And example of this can be seen in this answer.

Another solution would be to set the font of the title by using the titleTextAttributes property of the navigation controllers UINavigationBar. more info here. This solution is probably the most correct way to do it, but it is only available in iOS 5 and up.

Community
  • 1
  • 1
Dima
  • 23,484
  • 6
  • 56
  • 83