ios - UICollectionViewCell with rounded corners AND drop shadow not working -


i want uicollectionviewcells have rounded corners , drop shadows have run problem seems can have 1 or other, not both.

to round corners use code in initialization of cell:

calayer *layer = [self layer]; [layer setcornerradius:4]; [layer setrasterizationscale:[[uiscreen mainscreen] scale]]; [layer setshouldrasterize:yes]; 

to add drop shadow use code in initialization of cell:

calayer *layer = [self layer]; [layer setmaskstobounds:no]; [layer setrasterizationscale:[[uiscreen mainscreen] scale]]; [layer setshouldrasterize:yes]; [layer setshadowcolor:[[uicolor blackcolor] cgcolor]]; [layer setshadowoffset:cgsizemake(0.0f,0.5f)]; [layer setshadowradius:8.0f]; [layer setshadowopacity:0.2f]; [layer setshadowpath:[[uibezierpath bezierpathwithroundedrect:self.bounds cornerradius:layer.cornerradius] cgpath]]; 

to try , have rounded corners , drop shadow use code in initialization of cell:

calayer *layer = [self layer]; [layer setmaskstobounds:no]; [layer setcornerradius:4]; [layer setrasterizationscale:[[uiscreen mainscreen] scale]]; [layer setshouldrasterize:yes]; [layer setshadowcolor:[[uicolor blackcolor] cgcolor]]; [layer setshadowoffset:cgsizemake(0.0f,0.5f)]; [layer setshadowradius:8.0f]; [layer setshadowopacity:0.2f]; [layer setshadowpath:[[uibezierpath bezierpathwithroundedrect:self.bounds cornerradius:layer.cornerradius] cgpath]]; 

but results in drop shadow only.

is bug or doing wrong?

works me great:

-(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath     {         ...         cell.layer.maskstobounds = yes;         cell.layer.cornerradius = 6;         ...         return cell;     } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -