ios - How to make uiimageview circle.? -


i need make uiimageview in circle radius, using block of code taks.

-(void)viewwillappear:(bool)animated {      [self performselector:@selector(setstylecircleforimage:) withobject:_imageview afterdelay:0];      [super viewwillappear:yes]; }  -(void) setstylecircleforimage:(uiimageview *)imgview {      imgview.layer.cornerradius = _imageview.frame.size.height / 2.0;     imgview.clipstobounds = yes; } 

its working perfect in ios 5 when test in other device shape change don't know why happens. please make help.

better use mask make circle function

  - (void)viewdidload {     [super viewdidload];     [self makecircleimage: _imageview];  }    -(void)makecircleimage:(uiimageview *)img{       cgfloat img_width = img.bounds.size.width;       uigraphicsbeginimagecontextwithoptions(cgsizemake(img_width,img_width), no, 0);       cgcontextref c = uigraphicsgetcurrentcontext();       cgcontextsetfillcolorwithcolor(c, [uicolor blackcolor].cgcolor);       cgcontextfillellipseinrect(c, cgrectmake(0,0,img_width,img_width));       uiimage* maskim = uigraphicsgetimagefromcurrentimagecontext();       uigraphicsendimagecontext();        calayer* mask = [calayer new];       mask.frame = cgrectmake(0,0,img_width,img_width);       mask.contents = (id)maskim.cgimage;        img.layer.mask = mask;   } 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -