Resize title bar in navigation bar

Can I resize the title in the navigation bar? Some of the titles I want to use are too long to display at the current size, so I want to expand the title horizontally. This is what I have 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 my width is, it will not expand beyond a certain point. Here is what I see:

enter image description here

Can I get around this? thanks for the help

+4
source share
1 answer

AFAIK now has an easy way to do this. But you can use the methodUINavigationController

- (instancetype)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass;

to create a UINavigationController with a custom UINavigationBar.

, . nil navigationBarClass UINavigationBar, nil toolbarClass UIToolbar. UIKit.

+1

Source: https://habr.com/ru/post/1539649/


All Articles