UIToolbar tint on iOS 4(iOS 4 上的 UIToolbar 色调)
问题描述
刚刚在我的 iPhone 3GS 上切换到 iOS 4,我的一些应用程序坏了.
just switched to iOS 4 on my iPhone 3GS and some of my apps broke.
我遇到的一个问题是我有一个带有一些按钮的 UIToolbar,颜色为粉红色,在 3.1.3 操作系统上运行良好.升级到 iOS 4 后,工具栏仍然是有色的,但它包含的按钮不再受色调的影响.工具栏为粉红色,而按钮为常规蓝色.
One issue I had is that I had a UIToolbar with some buttons, tinted to pink, that worked well on the 3.1.3 OS. After upgrading to iOS 4, the toolbar was still tinted, but the buttons it contained were no longer affected by the tint. The toolbar was pink while the buttons were regular-blue.
在网上四处寻找,但没有找到这样的参考.
Looked around for it on the net, but found no reference of such a thing.
有人知道这个过程中发生了什么吗?
Anyone knows what broke in the process?
推荐答案
(这里必须坦白——我在发帖之前就知道答案了,只是不知道如何将这些数据加载到 StackOverflow.认为我找到的解决方案很有价值对于其他人,所以想在这里发布.我是新来的,所以请不要严厉批评:))
(must be frank here - I knew the answer before posting, just didn't know how to load this data to StackOverflow. Thought the solution I found was valuable for others, so wanted to post it here. I'm new here, so please no harsh critics :) )
所以最终问题是由 AFAICT 导致的,即操作系统中的行为变化.
So eventually the problem resulted from, AFAICT, a change in behavior in the OS.
如前所述,色调代码在升级之前就可以工作,并且是这样编写的:
As stated the tint code worked before the upgrade and was written like this:
// Toolbar content
NSArray *items=[NSArray arrayWithObjects: ... ]; // PSEUDO CODE HERE
[toolbar setItems:items];
// Add tint
toolbar.tintColor = [UIColor colorWithRed:0.83 green:0.43 blue:0.57 alpha:0.5];
我需要做的只是颠倒事情的顺序:
What I needed to do, was just reverse the order of things:
// Add tint
toolbar.tintColor = [UIColor colorWithRed:0.83 green:0.43 blue:0.57 alpha:0.5];
// Toolbar content
NSArray *items=[NSArray arrayWithObjects: ... ]; // PSEUDO CODE HERE
[toolbar setItems:items];
(如果你在 Interface Builder 中创建了 UIToolbar,你可以在那里改变它的色调,这也适用于按钮).
(If you created UIToolbar in Interface Builder, you can change it's tint there, and that applies for the buttons as well).
我猜在 iOS 4 之前色调会更新所有按钮,而在 iOS 4 中它不会,并且在添加按钮时,它们会检查现有的色调.但这只是一个猜测.该解决方案无论如何都有效..
I guess the tint updated all buttons before iOS 4, while in iOS 4 it doesn't and when adding buttons, they check for existing tint. But this is just a guess. The solution works anyhow..
希望这对某人有所帮助,并且我没有违反任何神圣的 SO 规则...
Hope this helps someone, and that I didn't violate any sacred SO rules...
干杯!
这篇关于iOS 4 上的 UIToolbar 色调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 4 上的 UIToolbar 色调
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01