UICollectionView Cell Shadow

后端 未结 4 1175
长情又很酷
长情又很酷 2021-02-06 02:07

I am trying to add shadow to my custom UICollectionViewCell, This is the code I am using in my custom collection view cell class:

self.layer.shadowO         


        
4条回答
  •  既然无缘
    2021-02-06 02:31

    Go to CustomCollectionViewCell.m file Worked for me. Hope it helps...

    - (id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
            //////// make shadow  of total view
            self.clipsToBounds = NO;
            self.layer.masksToBounds = NO;
            self.layer.shadowRadius = 5;
            self.layer.shadowOpacity = 0.5;
            self.layer.shadowColor = [UIColor blackColor].CGColor;
            self.layer.shadowOffset = CGSizeMake(0, 1);
            self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
    
            // make radius of the cell
            self.layer.cornerRadius = 5;
    
        }
        return self;
    }
    

提交回复
热议问题