Set a custom subclass of UINavigationBar in UINavigationController programmatically(以编程方式在 UINavigationController 中设置 UINavigationBar 的自定义子类)
问题描述
如果我以编程方式(没有 IB)实例化 UINavigationController,有谁知道如何使用我的自定义子类 UINavigationBar?
Does anyone know how can I use my custom subclass of UINavigationBar if I instantiate UINavigationController programmatically (without IB)?
在 IB 中拖动 UINavigationController 向我显示导航栏下并使用 Identity Inspectory 我可以更改类类型并设置自己的 UINavigationBar 子类,但以编程方式我不能, navigationBar 导航控制器的属性是只读的...
Drag a UINavigationController in IB show me an under Navigation Bar and using Identity Inspectory I can change class type and set my own subclass of UINavigationBar but programmatically I can't, navigationBar property of Navigation Controller is readonly...
如何以编程方式自定义导航栏?IB比代码"更强大"吗?我相信在 IB 中可以完成的所有事情也可以通过编程方式完成.
What should I do to customize the navigation bar programmatically? Is IB more "powerful" than "code"? I believed all that can be done in IB could be done also programmatically.
推荐答案
你不需要搞砸XIB,只需使用KVC.
You don't need to muck with the XIB simply use KVC.
[self.navigationController setValue:[[[CustomNavBar alloc]init] autorelease] forKeyPath:@"navigationBar"];
这篇关于以编程方式在 UINavigationController 中设置 UINavigationBar 的自定义子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:以编程方式在 UINavigationController 中设置 UINavigationBar 的自定义子类
基础教程推荐
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
