我尝试使用Objective-C获取UIImage
的一部分,但无法找到有关如何执行此操作的任何内容。我想帮助弄清楚如何做到这一点以及所涉及的步骤。
答案 0 :(得分:2)
试试这个..这将图像分成两部分,更具体地说是一半。
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);