Can you use UIAppearance to set the titleview of UINavigationItem?

时光怂恿深爱的人放手 提交于 2019-12-10 12:39:39

问题


I currently use this code to set the titleView of my navigation item:

- (void)viewDidLoad 
{ ...
   UIImage *navbarTitle = [UIImage imageNamed:@"navbartitleview1"];
   UIImageView *imageView = [[UIImageView alloc]initWithImage:navbarTitle];
   self.navigationItem.titleView =imageView;
}

Is there a way I could put this code using UIAppearance?

[UINavigationItem appearance]

is not valid.


回答1:


No you wan't be able to do that with UIAppearence, what you can is to have a UIViewController from where all the others UIViewController will inherit. Think way you avoid having to put that code in all your UIViewControllers.



来源:https://stackoverflow.com/questions/11230952/can-you-use-uiappearance-to-set-the-titleview-of-uinavigationitem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!