Search code examples
iphonemapkitcgcontextuicolor

iPhone - is CGContextSetStrokeColorWithColor not creating wanted color?


I am having some weird troubles with drawing some lines in an application. My drawRect is using

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:57 green:172 blue:255 alpha:1].CGColor]);
CGContextSetAlpha(context, 0.8);
CGContextSetLineWidth(context, POLYLINE_WIDTH);

The color that is supposed to be shown is something like this. However I am getting a dark grey color, does anyone know why this color could be getting skewed?


Solution

  • Try

    CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:57 / 255 green:172 / 255 blue:255 / 255 alpha:1].CGColor]);

    These functions are expecting a number from 0-1.