rainbowcolors = [[NSArray alloc] initWithObjects: [UIcolor colorWithRed:1 green:0 blue:0 Alpha:1],[UIcolor colorWithRed:1 green:0.25 blue:0 Alpha:1],[UIcolor colorWithRed:1 green:0.5 blue:0 Alpha:1],[UIcolor colorWithRed:1 green:0.75 blue:0 Alpha:1],[UIcolor colorWithRed:1 green:1 blue:0 Alpha:1],[UIcolor colorWithRed:0.75 green:1 blue:0 Alpha:1],[UIcolor colorWithRed:0.5 green:1 blue:0 Alpha:1],[UIcolor colorWithRed:0.25 green:1 blue:0 Alpha:1],[UIcolor colorWithRed:0 green:1 blue:0 Alpha:1],[UIcolor colorWithRed:0 green:1 blue:0.25 Alpha:1],[UIcolor colorWithRed:0 green:1 blue:0.5 Alpha:1],[UIcolor colorWithRed:0 green:1 blue:0.75 Alpha:1],[UIcolor colorWithRed:0 green:1 blue:1 Alpha:1],[UIcolor colorWithRed:0 green:0.75 blue:1 Alpha:1],[UIcolor colorWithRed:0 green:0.5 blue:1 Alpha:1],[UIcolor colorWithRed:0 green:0.25 blue:1 Alpha:1],[UIcolor colorWithRed:0 green:0 blue:1 Alpha:1],[UIcolor colorWithRed:0.25 green:0 blue:1 Alpha:1],[UIcolor colorWithRed:0.5 green:0 blue:1 Alpha:1],[UIcolor colorWithRed:0.75 green:0 blue:1 Alpha:1],[UIcolor colorWithRed:1 green:0 blue:1 Alpha:1],[UIcolor colorWithRed:1 green:0 blue:0.75 Alpha:1],[UIcolor colorWithRed:1 green:0 blue:0.5 Alpha:1],[UIcolor colorWithRed:1 green:0 blue:0.25 Alpha:1],nil];解决方法 更简单,使用 – [UIcolor colorWithHue:saturation:brightness:Alpha:],像这样:
NSMutableArray *colors = [NSMutableArray array];float INCREMENT = 0.05;for (float hue = 0.0; hue < 1.0; hue += INCREMENT) { UIcolor *color = [UIcolor colorWithHue:hue saturation:1.0 brightness:1.0 Alpha:1.0]; [colors addobject:color];}
这可以让您改变色调(或颜色),而不会改变屏幕上颜色的亮度,现在您很有可能无法保存.写得更简单,对于后来的读者来说也更加清晰.
总结以上是内存溢出为你收集整理的objective-c – iOS彩虹阵列全部内容,希望文章能够帮你解决objective-c – iOS彩虹阵列所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)