I’m overriding -drawRect: to draw some custom views. Usually, I’m drawing a filled rounded rect bezier path with a drop shadow. However, I’ve run into an annoying issue: when I set the shadow color, the fill color is also changed to the same color!
Is this a bug in Core Graphics or am I missing something here? Here’s an example of my code where I’m trying to draw a path with a shadow. translucentBlack and highlight are two different UIColor objects, but what gets drawn is a rounded rect that is filled with the highlight color as well as the shadow in the highlight color.
UIBezierPath* blackTranslucentRoundedRectPath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(CGRectGetMinX(frame) + 5, CGRectGetMinY(frame) + 5, CGRectGetWidth(frame) - 10, CGRectGetHeight(frame) - 10) cornerRadius: 8];
CGContextSetShadowWithColor(context, highlightOffset, highlightBlurRadius, highlight.CGColor);
[translucentBlack setFill];
[blackTranslucentRoundedRectPath fill];
Any ideas? Thanks!
What’s happening is that you can see your highlight color through your translucent black color. Change the
translucentBlackto any non-transparent color (make its alpha equal 1.0) and you should be fine.