iphone - How to make round shape of any view -
i want change shape of view square round. try cornerradious, round corner only. want make whole view round shape.
a uiview rectangular. however, can make look round (or shape @ all, actually) mask. so, make uiimage black circle (in transparent background). take cgimage of uiimage , make contents of calayer. finally, set calayer mask
of layer of view.
let suppose view 100 x 100. (not tested, should pretty right):
uigraphicsbeginimagecontextwithoptions(cgsizemake(100,100), no, 0); cgcontextref c = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(c, [uicolor blackcolor].cgcolor); cgcontextfillellipseinrect(c, cgrectmake(0,0,100,100)); uiimage* maskim = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); calayer* mask = [calayer new]; mask.frame = cgrectmake(0,0,100,100); mask.contents = (id)maskim.cgimage; view.layer.mask = mask;
Comments
Post a Comment