I am trying to draw a background image in my UIView. This is in a UIAlertView delegate method alertView: I pop the context because before this I was using a context in a OpenGL view called game.
UIGraphicsPopContext(); UIImage* background = [UIImage imageNamed:@'Background.png']; [background drawAtPoint:CGPointMake(0.0, 0.0)]; // fade the game out [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; [game setAlpha:0]; [UIView commitAnimations]; [game release];
I get a bunch of error messages such as : CGContextSaveGState: invalid context I tried it without popping. I guess what I need to do is find my UIView’s CGContextRef, and set that as my current context, but the documentation contains no info regarding CGContextRef. How can I display my image? I am trying to show the image behind the game view while it fades out.
Thanks.
Solved. All I had to do was put the UIImage in a UIImageView, and add it to the subview of my view.