由逗号分隔的plist键值的NSMutableArray

时间:2013-01-03 03:14:50

标签: iphone ios5 theos

我有一个存储缓存颜色的plist文件,它看起来像这样

<key>CachedColors</key>
<dict>
    <key>com.Halfbrick.Fruit</key>
    <string>0.00000,0.00000,0.00000</string>
    <key>com.apple.Preferences</key>
    <string>0.28824,0.37059,0.48235</string>
</dict>

我想要做的是使用3个值来创建UIColor,UIColor将根据包ID更改,值为红色,绿色和蓝色

但我希望UIColor在包ID更改时自动更改,我将其用作横幅的背景颜色,并说如果我在主屏幕上并获得通知,背景是白色,但如果我打开设置应用程序,我希望它从plist排序改为com.apple.Preferences的RGB值,在iOS 6中,状态栏背景在打开应用程序以匹配UINavigationBar时自动更改< / p>

我用过:

SBApplication *frontApp = [(SpringBoard*)[UIApplication sharedApplication] _accessibilityFrontMostApplication];
NSDictionary *statusBarCachedColors = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/cc.tweak.statuscolor.plist"      
NSString *colorString = [statusBarCachedColors objectForKey:frontApp];
NSArray *components = [colorString componentsSeparatedByString:@","];
UIColor *tintColor = [UIColor colorWithRed:[components[0] floatValue] green:[components[1] floatValue] blue:[components[2] floatValue] alpha:1.0];

我正在为越狱设备开发

1 个答案:

答案 0 :(得分:0)

从plist中拿起那个字符串后:

NSArray *components = [string componentsSeparatedByString:@","];
UIColor *color = [UIColor colorWithRed:[components[0] floatValue] green:[components[1] floatValue] blue:[components[2] floatValue] alpha:1];

...或者在较旧的编译器上

UIColor *color = [UIColor colorWithRed:[[components objectAtIndex:0] floatValue]
                                 green:[[components objectAtIndex:1] floatValue]
                                  blue:[[components objectAtIndex:2] floatValue] alpha:1];

如果问题包含其他内容,则很难遵循标点符号