Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UIColor *)fadeFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor withPercentage:(CGFloat)percentage
- {
- // get the RGBA values from the colours
- CGFloat fromRed, fromGreen, fromBlue, fromAlpha;
- [fromColor getRed:&fromRed green:&fromGreen blue:&fromBlue alpha:&fromAlpha];
- CGFloat toRed, toGreen, toBlue, toAlpha;
- [toColor getRed:&toRed green:&toGreen blue:&toBlue alpha:&toAlpha];
- //calculate the actual RGBA values of the fade colour
- CGFloat red = (toRed - fromRed) * percentage + fromRed;
- CGFloat green = (toGreen - fromGreen) * percentage + fromGreen;
- CGFloat blue = (toBlue - fromBlue) * percentage + fromBlue;
- CGFloat alpha = (toAlpha - fromAlpha) * percentage + fromAlpha;
- // return the fade colour
- return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
- }
RAW Paste Data