Reputation: 354
Here I'm trying to zoom cropped area and trying to do dropped area in circular format, but I didn't a get proper solution for this. So please help me anybody know this?
CALayer* layer = self.blurredImageView.layer;
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextAddRect(c, self.cropArea);
CGContextAddRect(c, rect);
CGContextEOClip(c);
CGContextSetFillColorWithColor(c, [UIColor blackColor].CGColor);
CGContextFillRect(c, rect);
UIImage* maskim = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Upvotes: 0
Views: 881
Reputation: 686
You just need to set your UIImageView's corner radius to half of it's width.
Like:
imgHspt.layer.cornerRadius = imgHspt.frame.size.width/2.0f;
imgHspt.layer.borderWidth = 0.5f;
imgHspt.clipsToBounds = YES;
imgHspt.layer.masksToBounds = YES;
This works with every image. Hope it works.
Upvotes: 0
Reputation: 5886
There is ready library on GitHub for round cropping like default contacts app of iOS.This may help you.
Upvotes: 1