iOS 4上的UIToolbar色调 [英] UIToolbar tint on iOS 4

查看:100
本文介绍了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色调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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