2

Apple recommends using CGContextSetFillColorWithColor instead of CGContextSetFillColor.

CGContextSetFillColor ... The current fill color space must not be a pattern color space. For information on setting the fill color when using a pattern color space, see CGContextSetFillPattern. Note that the preferred API to use is now CGContextSetFillColorWithColor.

Why is it 'preferred?'

Could continuing to use CGContextSetFillColor have consequences with drawRect? See my issue where drawRect leaves parts of the image behind.

It certainly causes problems when I mixed both.

CGContextSetFillColorWithColor(ctx, [[UIColor whiteColor] CGColor]);
CGRect fullBox = CGRectMake(xOffset, yOffset, kScoreBoxWidth * 17, 2 * (kScoreBoxHeight-2));
CGContextAddRect(ctx, fullBox);
CGContextFillPath(ctx);
  • Notice the graphs are filled with grey instead of green|yellow|red squares... enter image description here
Community
  • 1
  • 1
dfdumaresq
  • 1,618
  • 4
  • 17
  • 22
  • i'm not sure but I did some experiments drawing rects to BitMap contexts and passing in a color components struct like {1,0,0,0} to CGContextSetFillColor did not produce red while ` CGContextSetFillColorWithColor(bmc, [NSColor redColor].CGColor); ` did. I am also interested in any subtletees here. – Alex Bollbach Jul 01 '16 at 02:19

0 Answers0