ios 设置导航器navigationItem.titleVie

2017-06-12  本文已影响1153人  整个夏天
问题出现环境描述

应用window的rootViewController为UINavigationController对象nav

self.window.rootViewController=nav;

nav的RootViewController为自定义tabbar类,该自定义tabbar继承于UIViewController,里面可以加入任意你的tabbarItemView进行点击切换显示.

UINavigationController * nav =[[UINavigationController alloc]initWithRootViewController:self.tabbar];
图片.png

此时在vc中设置titleView无效

UIView * view =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
view.backgroundColor=[UIColor redColor];
self.navigationItem.titleView=view;
问题原因

只有在push进导航器的vc或者是作为导航器 rootViewController的vc才能够修改titleView.由于tabbar继承于UIViewController,且为导航器的rootViewController,所以如果要修改titleView只能够在tabbarView中去实现,在tabbar里面的vc去设置是不会出现效果的.

上一篇 下一篇

猜你喜欢

热点阅读