UINavigationBar TintColor 并不总是传播到 UIBarButtonItem 对象
问候! 我已将 **UINavigationBar's barStyle 设置为 UIBarStyleBlack,并将 tintColor 设置为某种颜色(黑色除外,以便获得颜色/渐变)。 就这么多效果很好。
现在...假设我将一个新的视图控制器推送到导航控制器堆栈上。 在这个特定的 VC 中,我希望导航栏变黑,但仅限于该 VC 内。
因此,在新 VC 的 viewWillAppear: 方法中,我将导航栏的 tintColor 设置为 nil(或 [UIColor blackColor] - 两者都有效) 。 在 viewWillDisappear: 中,我将 tintColor 更改回原来的样子。 再说一次,一切都很好。
直到我第二次(或更多)回到新的 VC。 如果我这样做,导航栏会再次变黑,但左栏按钮项目不会变黑! 相反,它保留了父 VC 的原始颜色!
我查看了各种示例代码(甚至是 Joe Hewitt 的 Three20 库,它似乎做了与我的照片控制器/浏览器相同的事情)。 据我所知,我正在做所有正确的事情,但我很困惑为什么除了我第一次进入新的 VC 之外,栏按钮项目没有更改为黑色。
欢迎提供线索/赞赏!
Greetings! I have set my **UINavigationBar'**s barStyle to UIBarStyleBlack, and the tintColor to a color (other than black so as to get the color/gradient going). That much works well.
Now ... let's say I push a new view controller onto the nav controller stack. In this particular VC, I want the nav bar to turn black, but only within this VC.
So, in the new VC's viewWillAppear: method, I set the nav bar's tintColor to nil (or [UIColor blackColor] - either one works). In viewWillDisappear:, I change the tintColor back to what it originally was. Again, all is well.
Until I go back into the new VC a second (or additional) time. If I do that, the nav bar turns black again, but NOT the left bar button item! Instead, it keeps the original color from the parent VC!
I've looked at all manner of sample code (even Joe Hewitt's Three20 library, which appears to do the same thing mine does for its Photo controller/browser). As far as I can tell, I'm doing all the right things, but I'm stumped as to why the bar button item isn't being changed to black for all but the first time I enter my new VC.
Clues welcome/appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,这是一个已知的 3.0 错误。
From what I hear this is a known 3.0 bug.
尝试添加到父视图控制器:
Try add to PARENT view controller:
希望能帮助到你。
Hope it helps.