UICollectionView单元格阴影 [英] UICollectionView Cell Shadow

查看:64
本文介绍了UICollectionView单元格阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向自定义 UICollectionViewCell 添加阴影,这是我在自定义集合视图单元格类中使用的代码:

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.shadowOffset = CGSizeMake(1, 0);
self.layer.shadowColor = [[UIColor blackColor] CGColor];
self.layer.shadowRadius = 5;
self.layer.shadowOpacity = .25;

这为集合视图单元格的组件提供了阴影.

This is giving shadow to the components of the collection view cell.

推荐答案

不要忘记添加这两行

self.clipsToBounds = false      
self.layer.masksToBounds = false

这篇关于UICollectionView单元格阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆