【问题标题】:Can you use UIAppearance to set the titleview of UINavigationItem?可以用 UIAppearance 来设置 UINavigationItem 的 titleview 吗?
【发布时间】:2012-06-27 16:30:48
【问题描述】:

我目前使用这段代码来设置我的导航项的titleView:

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

有没有办法可以使用 UIAppearance 放置此代码?

[UINavigationItem appearance]

无效。

【问题讨论】:

  • 简单地说,不。如果您正在查看头文件,则必须使用 UI_APPEARANCE_SELECTOR 标记属性。 UINavigationItem 也不符合 UIAppearance 协议。
  • 啊,原来如此,谢谢。

标签: ios uinavigationitem uiappearance titleview


【解决方案1】:

不,你不能用UIAppearence 做到这一点,你可以拥有一个UIViewController,所有其他 UIViewController 将从那里继承。想办法避免将代码放入所有UIViewControllers

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-30
    • 2016-02-25
    • 1970-01-01
    • 1970-01-01
    • 2011-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多