image in circle frame iOS [closed] image in circle frame iOS [closed] xcode xcode

image in circle frame iOS [closed]


I presume that you have your imageView inside your Cell, so what your have just to do for have the same effect is use a invisible border. Use this code for make this effect:

cell.yourImageView.layer.cornerRadius = cell.yourImageView.frame.size.height /2;cell.yourImageView.layer.masksToBounds = YES;cell.yourImageView.layer.borderWidth = 0;

Your UIImageView must have the same height and width also you have to import the quartzCore framework in your project


apparently i can make a rounded rect like this

float fw, fh;if (ovalWidth == 0 || ovalHeight == 0) {    CGContextAddRect(context, rect);    return;}CGContextSaveGState(context);CGContextTranslateCTM (context, CGRectGetMinX(rect), CGRectGetMinY(rect));CGContextScaleCTM (context, ovalWidth, ovalHeight);fw = CGRectGetWidth (rect) / ovalWidth;fh = CGRectGetHeight (rect) / ovalHeight;CGContextMoveToPoint(context, fw, fh/2);CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1);CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1);CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1);CGContextClosePath(context);CGContextRestoreGState(context);

and then put the image inside, it will be automatically clipped:

 CGContextRef context = UIGraphicsGetCurrentContext();CGContextSaveGState(context);addRoundedRectToPath(context, self.frame, 10, 10);CGContextClip(context);[image drawInRect:self.frame];CGContextRestoreGState(context);