我已经阅读了有关为添加阴影而添加第二个视图的各种帖子,但如果我想在 UICollectionViewCell
中添加它,我仍然无法使其工作。 我对 UICollectionViewCell
进行了子类化,这是我添加各种 UI 元素到单元格内容视图并将阴影添加到层中的代码:
[self.contentView setBackgroundColor:[UIColor whiteColor]];
self.layer.masksToBounds = NO;
self.layer.shadowOffset = CGSizeMake(0, 1);
self.layer.shadowRadius = 1.0;
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowOpacity = 0.5;
[self.layer setShadowPath:[[UIBezierPath bezierPathWithRect:self.bounds] CGPath]];
我想知道如何为 UICollectionViewCell
添加圆角和阴影。