Question

i have a color code coming from server and I am using that color to set the color of a UIView. Now I want to set the border of the UIView with a color which is darker(higher in intensity) than the color that I am getting. How can this be possible ? Please let me know and do tell me if you have any ideas to do the same.

view.backgroundColor = [view setColor].CGColor;
view.layer.borderWidth = 1.5;
const CGFloat* components = CGColorGetComponents(view.setColor.CGColor);
NSLog(@"Red: %f", components[0]);
NSLog(@"Green: %f", components[1]);
NSLog(@"Blue: %f", components[2]);
NSLog(@"Alpha: %f", CGColorGetAlpha(view.setColor.CGColor));

/*need to set this border color as a dark color*/<br>
view.layer.borderColor = [view setColor].CGColor;
Was it helpful?

Solution

Take each color value down a notch. So something like

[UIColor colorWithRed:oldRed*0.75f green:oldGreen*0.75f blue:oldBlue*0.75f alpha:1.0]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top