Skip to content

Instantly share code, notes, and snippets.

@k06a
Created June 16, 2015 14:59
Show Gist options
  • Save k06a/ee1d62f85b06a7944bcf to your computer and use it in GitHub Desktop.
Save k06a/ee1d62f85b06a7944bcf to your computer and use it in GitHub Desktop.
UIColor+Interpolation
+ (UIColor *)colorBetweenColor:(UIColor *)color1
andColor:(UIColor *)color2
atProgress:(CGFloat)progress
{
CGFloat r1,g1,b1,a1,r2,g2,b2,a2;
[color1 getRed:&r1 green:&g1 blue:&b1 alpha:&a1];
[color2 getRed:&r2 green:&g2 blue:&b2 alpha:&a2];
return [UIColor colorWithRed:r1+(r2-r1)*progress
green:g1+(g2-g1)*progress
blue:b1+(b2-b1)*progress
alpha:a1+(a2-a1)*progress];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment