我需要为给定索引返回特定的UIColor。
我想的UIColors基本上存储为NSArrays在NSDictionary中存储UIColors并检索它们?
TypeColors = [[NSDictionary中的alloc] initWithObjectsAndKeys:
@ “1”,[NSArray的arrayWithObjects:[NSNumber的numberWithFloat:0.5],[的NSNumber numberWithFloat:0.5],[NSNumber的 numberWithFloat:0.5],[NSNumber的numberWithFloat:1.0],零],
@ “5”,[NSArray的arrayWithObjects:[NSNumber的numberWithFloat:1.0],[的NSNumbernumberWithFloat:0.5],[NSNumber numberWithFloat:0.1],[NSNumber numberWithFloat:1.0],nil] ,nil]; //无表示对象和键的结尾。
在这里,我想从字典检索的UIColor回:
a = 5;
NSArray* colorArray = [TypeColors objectForKey:a];
UIColor* color = [UIColor colorWithRed:[colorArray objectAtIndex:0]
green:[colorArray objectAtIndex:1] blue:[colorArray objectAtIndex:2]
alpha:[colorArray objectAtIndex:3]];
它总是返回我是零,任何人都知道这是为什么? 谢谢!