简体   繁体   English

如何在 iOS 中移除 UICollectionView 周围的边框?

[英]How to remove border around UICollectionView in iOS?

I have made a UICollectionView in my project.It is custom UICollectionViewCell .When i run the app it shows the black border around the UICollectionViewCell .Please tell me how can i remove that border around the custom cell?我在我的项目中创建了一个UICollectionView 。它是自定义UICollectionViewCell 。当我运行应用程序时,它会显示UICollectionViewCell周围的黑色边框。请告诉我如何删除自定义单元格周围的边框?

在此处输入图片说明

UICollectionViewCell *cell = [[UICollectionViewCell alloc] init];
cell.layer.borderColor = (__bridge CGColorRef _Nullable)([UIColor clearColor]);

cell is a name given to Collection View cell element. cell 是集合视图单元格元素的名称。 This line of code will make the border color transparent.这行代码将使边框颜色透明。

Swift 5 version斯威夫特 5 版本

var cell = UICollectionViewCell()
cell.layer.borderColor = UIColor.clear.cgColor

Tested the code in Swift 5在 Swift 5 中测试代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM