How to crop an image?

Discussion in 'iOS Programming' started by azg442, May 13, 2009.

  1. azg442 macrumors newbie

    May 10, 2009
    How would you crop an image using CGrectMake? I'm having a lot of trouble. Thanks!

    Here is the code im using...

    UIImage *spriteImage = [UIImage imageNamed:@"spritesheet.png"];
    sprite.image = spriteImage;	
    sprite.frame = CGRectMake(110.0, 180.0, 100.0, 100.0); 
  2. kainjow Moderator emeritus


    Jun 15, 2000
    One way is to use CGImageCreateWithImageInRect(). Get the CGImage from your UIImage, pass it to that function, then create a new UIImage from the CGImage you just created.

Share This Page