1十绑、// 設(shè)置uicollection 的 橫向滑動flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
2、// 源數(shù)據(jù)首位 添加數(shù)組最后的元素 [self.dataArray addObject:_array.lastObject];
? ? ? // 源數(shù)據(jù)末尾 補充第一個元素? ? [self.dataArray addObject:_array.firstObject];
3、設(shè)置scrollView Delegate方法:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
? ? if(scrollView == self.collectionView) {
? ? ? ? //如果滑動到倒數(shù)第一張悠瞬。則collection滾動到第二張
? ? ? ? if(scrollView.contentOffset.x == (self.dataArray.count-1)*(self.frame.size.width) ) {
? ? ? ? ? ? [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0] atScrollPosition:UICollectionViewScrollPositionLeft animated:false];
? ? ? ? }
????????//如果滑動到第一張。則collection滾動倒數(shù)第一張
? ? ? ? else if(scrollView.contentOffset.x ==0){
? ? ? ? ? ? [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:(self.dataArray.count-2) inSection:0] atScrollPosition:UICollectionViewScrollPositionLeft animated:false];
? ? ? ? }else{
? ? ? ? ? ? //? ? ? ? ? ? 正常滾動? ? ? ? }
? ? }
}