Last active
December 17, 2015 18:49
-
-
Save Kursulla/5656038 to your computer and use it in GitHub Desktop.
Split one image into two images and place them into separated containers [Objective-C, objc, xcode, ios]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIImage *image = [UIImage imageNamed:@"some_image.png"]; | |
CGImageRef tmpImgRef = image.CGImage; | |
//Taking left part of image from 0 to half of width | |
CGImageRef leftImgRef = CGImageCreateWithImageInRect(tmpImgRef, CGRectMake(0, 0, image.size.width/2.0, image.size.height )); | |
UIImage *leftUIImage = [UIImage imageWithCGImage:leftImgRef]; | |
CGImageRelease(leftImgRef); | |
//Taking right of image from half of width to full width | |
CGImageRef rightImgRef = CGImageCreateWithImageInRect(tmpImgRef, CGRectMake(image.size.width / 2.0, 0, image.size.width/2.0, image.size.height)); | |
UIImage *rightUIImage = [UIImage imageWithCGImage:rightImgRef]; | |
CGImageRelease(rightImgRef); | |
//Placing images into separated containers (UIImageView) in order to manipulate with them | |
[_leftImage setImage:leftUIImage]; | |
[_rightImage setImage:rightUIImage]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment