uiview - IOS: round the cournes of a uicollectionViewCell clipin it's contents -


i have collection view multiple cell styles , sizes want round corners of cell using helper function:

void roundcornersofaview(uiview *view, cgfloat radius, bool shadow){     calayer* layer = [view layer];     [layer setcornerradius:radius];     [layer setbordercolor:[uicolor blackcolor].cgcolor];      [layer setmaskstobounds:yes]; //    calayer* mask = [calayer layer]; //    [mask setframe:cgrectmake(layer.frame.origin.x, layer.frame.origin.y, layer.frame.size.width, layer.frame.size.height)]; //    [mask setcornerradius:radius]; //    [layer setmask:mask];     if (shadow) {         [layer setborderwidth:0.5f];         //[layer setmaskstobounds:no];         [layer setshadowcolor:[uicolor blackcolor].cgcolor];         [layer setshadowopacity:1.0];         [layer setshadowradius:1.0];         [layer setshadowoffset:cgsizemake(0.0, 0.0)];     }     [layer setmaskstobounds:yes]; } 

using in cell row @ index path:

uicollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:... forindexpath:indexpath];  roundcornersofaview([cell contentview], 30, yes); 

the problem images on cell not clipped in rounded courners, neither labels or other subviews, clips background color... best way round courners , clip content instagram app?

calling this:

roundcornersofaview(cell, 30, yes); 

using helper function this:

void roundcornersofaview(uiview *view, cgfloat radius, bool shadow){     calayer* layer = [view layer];     [layer setcornerradius:radius];     [layer setborderwidth:0.0f];     if (shadow) {             [layer setbordercolor:[uicolor blackcolor].cgcolor];             [layer setborderwidth:0.1f];             [layer setshadowcolor:[uicolor blackcolor].cgcolor];             [layer setshadowopacity:0.5];             [layer setshadowradius:1.5];             [layer setshadowoffset:cgsizemake(0.0, 1.0)];         }         [layer setmaskstobounds:yes];     } 

the problem was sending content view instead of cell itself.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -