我怎样才能将UI
Image分成两半(从中间开始),这样就会产生两个图像?
解决方法
你可以试试这个,
UIImage *image = [UIImage imageNamed:@"yourImage.png"]; CGImageRef tmpImgRef = image.CGImage; CGImageRef topImgRef = CGImageCreateWithImageInRect(tmpImgRef,CGRectMake(0,image.size.width,image.size.height / 2.0)); UIImage *topImage = [UIImage imageWithCGImage:topImgRef]; CGImageRelease(topImgRef); CGImageRef bottomImgRef = CGImageCreateWithImageInRect(tmpImgRef,image.size.height / 2.0,image.size.height / 2.0)); UIImage *bottomImage = [UIImage imageWithCGImage:bottomImgRef]; CGImageRelease(bottomImgRef);
希望这可以帮到你,:)