您可以使用UIAppearance设置UINavigationItem的标题视图吗? [英] Can you use UIAppearance to set the titleview of UINavigationItem?

查看:85
本文介绍了您可以使用UIAppearance设置UINavigationItem的标题视图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前使用此代码设置导航项目的titleView:

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;
}

有没有一种方法可以使用UIAppearance放置此代码?

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

[UINavigationItem appearance]

无效.

推荐答案

不,您将无法使用UIAppearence做到这一点,您可以拥有一个UIViewController,所有其他UIViewController将从该UIViewController继承.想一想,您不必在所有UIViewControllers中放入该代码.

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.

这篇关于您可以使用UIAppearance设置UINavigationItem的标题视图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆