经过几个小时的谷歌搜索,我没有找到解决方案..
我想将这些属性添加到单元格,但这段代码不起作用
AppCell *cell = [[AppCell alloc] init];
cell.layer.cornerRadius = 5.0;
cell.layer.shadowColor = [[UIColor blackColor] CGColor];
cell.layer.shadowOpacity = 1.0;
cell.layer.shadowRadius = 10.0;
cell.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);
解决办法是什么?? .. 非常感谢您提前
最佳答案
首先,创建一个 CustomCell,它是 UICollectionViewCell 的子类。然后,将该 CustomCell.h 文件导入到您的 collectionView 的 Controller 中。
如果你想在一些单元格上设置这些属性,使用委托(delegate)方法 - (UICollectionViewCell *)cellForItemAtIndexPath:(NSIndexPath *)indexPath
如果你想为所有单元格设置这些属性,只需将它们放在 CustomCell.m 中。记住导入 QuartzCore 框架。
关于ios - 可以在 UICollectionView 中自定义单元格吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16379828/