水平滚动UICollectionView一直到右/最后一个单元格

时间:2016-09-14 08:58:12

标签: ios swift uicollectionview

我有一个包含4个单元格的UICollectionView。 4个单元中的最后一个位于屏幕中间。如何以编程方式向右滚动,以便4个单元格中的第一个位于屏幕中间?

我试过了:

if (self.activeSection == .WISHES){
     cell.neighbourhoodHeaderCollectionView.setContentOffset(CGPointMake(CGFloat.max, 0), animated: false)
}

现在如何:

enter image description here

需要如何:

enter image description here

1 个答案:

答案 0 :(得分:1)

使用此...

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(0/*top*/, 5/*left*/, 0/*bottom*/, 5/*right*/);
}