This might be a simple one. I am trying to create multiple UIView with different colors using a For-loop:
float colorGrade = 255.0 / 160;
for (int i = 0; i < 160; i++)
{
float finalColor = colorGrade * i;
if (finalColor > 255)
finalColor = 255;
UIView *viewColor = [[UIView alloc] initWithFrame:CGRectMake(i * 2, 0, 2, viewHeight)];
UIColor *bgColor = [UIColor colorWithRed:finalColor green:0 blue:0 alpha:1];
[viewColor setAlpha:1];
[viewColor setBackgroundColor:bgColor];
[viewColor setTag:i + 1];
[touchPadView addSubview:viewColor];
}
Views are created, but they are all ended up with the same colors. Something is missing here?
Thanks.