Ios UICollectionViewFlowLayout左侧的间隙
我使用UICollectionViewFlowLayout来显示网格视图,这就是我所看到的 问题在于左侧的间隙。我对使用UICollectionViewFlowLayout有点陌生,所以我不知道如何消除那里的差距Ios UICollectionViewFlowLayout左侧的间隙,ios,swift,uicollectionview,uicollectionviewlayout,Ios,Swift,Uicollectionview,Uicollectionviewlayout,我使用UICollectionViewFlowLayout来显示网格视图,这就是我所看到的 问题在于左侧的间隙。我对使用UICollectionViewFlowLayout有点陌生,所以我不知道如何消除那里的差距 请帮助要减少左侧的空间,您可以在UICollectionViewFlowLayout上设置sectionInset属性 flowLayout.sectionInsets = UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right:
请帮助要减少左侧的空间,您可以在
UICollectionViewFlowLayout
上设置sectionInset
属性
flowLayout.sectionInsets = UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
或者,您可以实现此方法:
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
}
如果委托对象未实现
collectionView:layout:InsetForSectionIndex:method,流布局
使用此属性中的值设置每个部分的边距
来源:要减少左侧的空间,您可以在
UICollectionViewFlowLayout
上设置sectionInset
属性
flowLayout.sectionInsets = UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
或者,您可以实现此方法:
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
}
如果委托对象未实现
collectionView:layout:InsetForSectionIndex:method,流布局
使用此属性中的值设置每个部分的边距
来源:尝试使用:
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(5, 5, 5, 5); //desired values
}
希望有帮助。尝试使用:
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(5, 5, 5, 5); //desired values
}
希望有帮助。我的第一个猜测是查看
部分插图。您可以直接在流布局上设置它们:
flowLayout.sectionInsets = UIEdgeInsets(...)
或通过~UICollectionViewDelegateFlowLayout`方法:
optional func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
insetForSectionAtIndex section: Int) -> UIEdgeInsets {
}
我的第一个猜测是检查部分插图。您可以直接在流布局上设置它们:
flowLayout.sectionInsets = UIEdgeInsets(...)
或通过~UICollectionViewDelegateFlowLayout`方法:
optional func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
insetForSectionAtIndex section: Int) -> UIEdgeInsets {
}
嘿。如果您使用的是自动布局,则问题可能在于页边距。检查UICollectionView
Hey的前导约束。如果您使用的是自动布局,则问题可能在于页边距。检查UICollectionView的前导约束