【发布时间】:2016-10-18 16:39:22
【问题描述】:
我想在我的UICollectionView 上设置 2 个圆顶角
我有一个包含我的UICollectionView 的UIView contentView。如果我将UICollectionView 的cornerRadius 设置为true,并将clipsToBound 设置为true,则此方法有效,只是它会将所有4 个角 变圆。
看来我需要申请UIBezierPath,但一旦我这样做了,我就会遇到问题:
- 如果我将
UIBezierPath应用于UICollectionView本身,我只能看到我的第一个单元格,而当我滚动到第二个单元格时,我什么也看不到。
[
[UIBezierPath bezierPathWithRoundedRect:self.collectionView.bounds
byRoundingCorners:UIRectCornerTopLeft cornerRadii:CGSizeMake(9.0,
9.0)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = self.collectionView.bounds;
maskLayer.path = maskPath.CGPath;
self.collectionView.layer.mask = maskLayer;
- 如果我尝试将
UIBezierPath应用到 contentView,与上述相同,但我将 self.collectionView 替换为 self.contentView >,边角一点都不圆。
【问题讨论】:
-
您是否尝试过为整个 collectionView 添加圆角半径并将 clipsToBounds 设置为 YES?
-
@Rikh 请查看我编辑的问题
-
你是否为collectionViewCell或collectionView过度使用drawRect?
标签: ios uicollectionview uicollectionviewcell uibezierpath rounded-corners