Andrew
Andrew

Reputation: 16051

Getting invalid context errors

I don't have much code thus far, only this to start:

UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0);

    CGContextRef context = UIGraphicsGetCurrentContext();
CGMutablePathRef outerPath;

CGMutablePathRef highlightPath;

CGRect outerRect = rectForRectWithInset(bounds, 1); 

CGRect highlightRect = CGRectMake(outerRect.origin.x,
                                      outerRect.origin.y + 1,
                                      outerRect.size.width,
                                      outerRect.size.height);

And then the problematic bit, which when commented out, the error goes away:

CGContextSaveGState(context);

CGContextAddPath(context, highlightPath);
CGContextSetFillColorWithColor(context, [[UIColor colorWithWhite:1.0 alpha:0.05]CGColor]);
CGContextFillPath(context);

CGContextRestoreGState(context);

Below that is simply:

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

Upvotes: 1

Views: 217

Answers (1)

Jesse Gumpo
Jesse Gumpo

Reputation: 4787

it seems that either the bounds 0,0,0,0 or there is a problem with the highlightPath. Where do these values come from?

Upvotes: 1

Related Questions