我想将UIButton颜色从棕色更改为深棕色。我该怎么做
myButton.backgroundColor = [UIColor brownColor];
关于如何将这种棕色变成深棕色的任何想法。感谢帮助。
最佳答案
如果您只想特别选择深棕色,则可以手动指定它:
myButton.backgroundColor = [UIColor colorWithHue:1.0/12 saturation:2.0/3 brightness:4.0/10 alpha:1];
(默认的棕色具有6.0 / 10的亮度。)
如果您希望能够总体上使颜色变深,则可以这样做:
UIColor *color = UIColor.brownColor;
CGFloat hue, saturation, brightness, alpha;
[color getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
brightness *= .8;
UIColor *darkerColor = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:alpha];
关于ios - UIButton颜色变化,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9010482/