Search code examples
iphonexcodeuiimageviewquartz-2d

Inserting a Background Image using Quartz2d and Context?


I have written a game using Quartz2d. I would like a insert a background image to the game. I have tried doing this using the view.insertSubView method however the background image is always placed on top of the other sprites. Even using sendSubviewToBack does not solve this. I assume I need to somehow draw the background image directly onto the context ?

Thanks in advance for any help,

Martin


Solution

  • You can draw an image with

    UIImage *myImage = [UIImage imageNamed:@"imageName.png"];
    [myImage drawAtPoint:CGPointMake(0, 0)];
    

    But if it's always the same you should maybe add a UIImageView below your UIView which draw all your game ^^ (but not in the View like you tried, but in the superview)