为所有navigationcontroller和navigationitem设置titleview [英] Set titleview for all navigationcontroller and navigationitem

查看:129
本文介绍了为所有navigationcontroller和navigationitem设置titleview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[[[UINavigationBar appearance] setTitleView:button]

我尝试使用上面的代码行将标题视图设置为所有导航项的按钮,但它不起作用。如何通过在appdelegate中编写小代码来为项目中的所有导航栏设置标题视图?

I tried to set title view as button for all navigation item using above line of code but it is not working.How can I set title view for all navigation bars in my project by writing small code in appdelegate ?

推荐答案

自定义导航栏的外观


可以修改barStyle,tintColor和半透明的
属性,但是你不能直接直接更改UIView级属性
,例如frame,bounds,alpha或hidden properties 。

it is alright to modify the barStyle, tintColor, and translucent properties, but you must never directly change UIView-level properties such as the frame, bounds, alpha, or hidden properties directly.

有关详细信息,请参阅apple doc UINavigationBar类参考

For more detail you can follow apple doc UINavigationBar Class Reference

编辑 - >

我解决了您的查询

[[UINavigationBar appearance] addSubview:yourView];  

其他导航相关查询

这篇关于为所有navigationcontroller和navigationitem设置titleview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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