-4

我尝试参与UIImage使用 Objective-C,但找不到任何有关如何执行此操作的信息。我想帮助弄清楚如何做到这一点以及所涉及的步骤。

4

1 回答 1

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);
于 2013-06-15T14:53:34.670 回答