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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -