Custom navigationBar on moreNavigationController

2019-09-05 06:04发布

问题:

Hot to customize navigation bar that appear on "More" tab in UITabBarController to have 2 px line (in different color) as bottom border?

I created subclass of the UINavigationBar that overrides drawrect: method with drawing of that line, and that works for first four tabs, except tabs that are under more navigation controller.

Any help?

回答1:

#import <objc/runtime.h>

And dynamically set the class of the more view controller's navigation bar:

object_setClass(yourTabBarController.moreNavigationController.navigationBar, 
                [YourNavigationBarSubClass class]);


回答2:

If you wanna change the background image you can do it inserting a UIImageView in the default navigation bar

[self.navigationController.navigationBar addSubview:[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"navBar"]]];