自定义 UINavigationController UIToolbar 子类 [英] Custom UINavigationController UIToolbar subclass

查看:39
本文介绍了自定义 UINavigationController UIToolbar 子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 UINavigationController 中的子类 UIToolbar.我知道这可以通过 Interface Builder 完成,但我需要以编程方式完成.

I need to work with a subclassed UIToolbar in the UINavigationController. I know this can be done via Interface Builder but I need it to be done programatically.

文档声明 UINavigationController 工具栏属性是只读的,所以我对如何进行操作有点不知所措.

The docs state that the UINavigationController toolbar property is readonly so I'm at a bit of a loss as to how I proceed.

相关:

推荐答案

一个新的 init* 方法从 iOS 5 开始可用

A new init* method has been available since iOS 5

- (instancetype)initWithNavigationBarClass:(Class)navigationBarClass 
                              toolbarClass:(Class)toolbarClass

也不要忘记

...在屏幕上显示导航控制器之前,您负责添加根视图控制器.

... you are responsible for adding a root view controller before presenting the navigation controller onscreen.

这篇关于自定义 UINavigationController UIToolbar 子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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