PDA

View Full Version : How to crop an image?




azg442
May 13, 2009, 06:23 PM
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);



kainjow
May 13, 2009, 06:50 PM
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.