I have found the following code from this link: iphone - How to draw a rounded rectangle in Core Graphics / Quartz 2D? - Stack Overflow
So pretty much this is the code:
- (UIImageView*)roundImageView:(CGFloat)rad {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGRect rrect = ivprofilePicture.bounds;
CGFloat radius = rad;
CGFloat minx = CGRectGetMinX(rrect), midx = CGRectGetMidX(rrect), maxx = CGRectGetMaxX(rrect);
CGFloat miny = CGRectGetMinY(rrect), midy = CGRectGetMidY(rrect), maxy = CGRectGetMaxY(rrect);
CGContextMoveToPoint(context, minx, midy);
CGContextAddArcToPoint(context, minx, miny, midx, miny, radius);
CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius);
CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius);
CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFillStroke);
UIImageView *imageView;
return imageView;
}
I would then call it like this:
myImageView = [self roundImageView:10];
The problem is, how would I return a UIImageView from this code? I have already created a method that takes in a radius parameter and returns an UIImageView. The rect in the code above is already set to original UIImageView's bounds too.
However, I just have no idea how I would return the UIImageView with its rounded corners from this code.
Does anyone have any ideas?
Thanks!