-4

I tried to take a part of an UIImage using Objective-C, but can't find anything about how to do this. I'd like help figuring out how to do this and the steps involved.

1 Answers1

2

Try this.. This splits the image in two parts, more speciffically in half.

    UIImage *image = [UIImage imageNamed:@"theImageYouWantToSplit.png"];
CGImageRef temporaryImageReference = image.CGImage;
CGImageRef topImageReference = CGImageCreateWithImageInRect(temporaryImageReference, CGRectMake(0, 0, image.size.width, image.size.height / 2.0));
UIImage *topImage = [UIImage imageWithCGImage:topImageReference];
CGImageRelease(topImageReference);

CGImageRef bottomImageReference = CGImageCreateWithImageInRect(temporaryImageReference, CGRectMake(0, image.size.height / 2.0,  image.size.width, image.size.height / 2.0));
UIImage *bottomImage = [UIImage imageWithCGImage:bottomImageReference];
CGImageRelease(bottomImageReference);