Reputation: 64684
Is it possible to change the size of the titleview in a navigation bar? Some of the titles I want to use are too long to display in the current size, so I want to horizontally expand the titleview. This is what I've tried so far:
UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(0,0,500,32)];
[testView setBackgroundColor:[UIColor redColor]];
self.navigationItem.titleView = testView;
No matter how big I make the width it stil won't expand beyond a certain point. This is what I see:
Is there anyway to get around this? Thanks for the help
Upvotes: 4
Views: 1210
Reputation: 17053
AFAIK there is now easy way to do so. But you can use UINavigationController
's method
- (instancetype)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass;
to create UINavigationController with custom UINavigationBar.
Use this initializer to make the navigation controller use your custom bar class. Passing nil for navigationBarClass will get you UINavigationBar, nil for toolbarClass gets UIToolbar. The arguments must otherwise be subclasses of the respective UIKit classes.
Upvotes: 1