ios - UIImage not clipped by clipping path -


i have uiview subclass contains uiimageview. want image appear circular, did this:

- (void)drawrect:(cgrect)rect {     cgcontextref ctx = uigraphicsgetcurrentcontext();     cgcontextsavegstate(ctx);     cgpathref clippath = [uibezierpath bezierpathwithroundedrect:rect cornerradius:17].cgpath;     cgcontextaddpath(ctx, clippath);     cgcontextclip(ctx);     [self.imageview.image drawinrect:rect];     cgcontextrestoregstate(ctx); } 

however, images not circular, regular rectangles. what's issue?

ac couple options have either breate cornerradius on uiimageview appears circular or remove uiimageview uiview's subviews.

in first case don't need have custom drawing since circle picture want drawn in uiimageview cornerradius (and clipstobounds enabled).

in second don't need uiimageview @ all, uiimage. uiimageview way display uiimage on screen, , if that's taken care of in custom drawing of view don't need uiimageview.

given these options believe uiimageview cornerradius efficient. custom drawing takes bit of processor time uiimageview take care of you.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -