CLIP CIRCLE PART OF AN SQUARE IMAGE WITH PATH

UIImage *imageOld = [UIImage imageNamed:@”GC.png”];

CGSize newSize = CGSizeMake(imageOld.size.width, imageOld.size.height);

UIGraphicsBeginImageContext(newSize);

CGContextRef context = UIGraphicsGetCurrentContext();
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddEllipseInRect(path, NULL, CGRectMake(0, 0, imageOld.size.width, imageOld.size.height));
CGContextAddPath(context, path);
CGContextClip(context);
CGPathRelease(path);
CGPoint topLeftOffset = CGPointMake(0,0);
[imageOld drawAtPoint: topLeftOffset];

UIImage *newCircleImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

Advertisements
CLIP CIRCLE PART OF AN SQUARE IMAGE WITH PATH

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s