【问题标题】:Unable to apply Shadow on all the sides of collectionView Cell无法在 collectionView Cell 的所有侧面应用阴影
【发布时间】:2017-01-18 12:36:37
【问题描述】:

我正在尝试制作所有侧面的阴影,但它仅适用于底部和右侧。知道我缺少什么吗? 这是我的代码

    cell.layer.shadowColor = [UIColor lightGrayColor].CGColor;
    cell.layer.shadowOffset = CGSizeMake(2.5f, 2.5f);
    cell.layer.shadowRadius = 3.0f;
    cell.layer.shadowOpacity = 0.5f;
    cell.layer.masksToBounds = NO;

【问题讨论】:

标签: ios objective-c swift shadow


【解决方案1】:

阴影超出了集合视图的范围,因此被集合视图剪裁了。

您可以通过设置比shadowRadius 更宽的sectionInset 来解决此问题(因此单元格和包含的集合视图之间存在间隙),或者设置collectionView.clipsToBounds = false

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-07
    • 1970-01-01
    • 2012-07-09
    • 1970-01-01
    • 2020-12-17
    • 1970-01-01
    • 2013-03-20
    • 2015-05-04
    相关资源
    最近更新 更多