ios - UIImageView round border with margin -


i'm using code create rounder uiimageview:

-(void) makeimageviewrounded {     self.layer.backgroundcolor=[[uicolor greencolor] cgcolor];     self.layer.cornerradius= self.frame.size.height /2;     self.clipstobounds = yes;     self.layer.maskstobounds = yes;     self.layer.borderwidth=1.5;     self.layer.bordercolor=[[uicolor graycolor] cgcolor]; } 

this outcome (ignore background if jpg.. starts rounded border):

enter image description here

i want create margin between image , rounded border outcome (ignore background if jpg.. starts rounded border):

enter image description here

how can achieve ?

i figured way, make uiview subclass called circleview, in implementation, add

- (id)initwithframe:(cgrect)frame {     self = [super initwithframe:frame];     if (self) {         // initialization code         [self setbackgroundcolor:[uicolor clearcolor]];      }     return self; }  - (void)drawrect:(cgrect)rect {     cgcontextref context = uigraphicsgetcurrentcontext();     cgcontextsetlinewidth(context, 20.0);     cgcontextsetstrokecolorwithcolor(context,                                      [uicolor lightgraycolor].cgcolor);     cgrect rectangle = self.bounds;     cgfloat linewidth = self.superview.layer.borderwidth;     rectangle = cgrectinset(rectangle, linewidth, linewidth);     cgcontextaddellipseinrect(context, rectangle);     cgcontextstrokepath(context); }        //then add circle view imageview     circleview *circle = [[circleview alloc]initwithframe:imageview.bounds];     [imageview addsubview:circle]; 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -