其实不是真正意义上的循环滚动,只是判断当它快达到数组结尾时,把那个数组重新排序下,然后将原来加在UIScrollView上的remove,重新addsubview一次,有一点需要注意的是,为了不使其APP滚动过渡时闪一下,需要 exchangeObjectAtIndex 即重新排序数组
for (UIView *view in _myscrollView.subviews) {
[view removeFromSuperview];
}
[self.applistArray exchangeObjectAtIndex:0 withObjectAtIndex:(self.applistArray.count-5)];
[self.applistArray exchangeObjectAtIndex:1 withObjectAtIndex:(self.applistArray.count-4)];
[self.applistArray exchangeObjectAtIndex:2 withObjectAtIndex:(self.applistArray.count-3)];
[self.applistArray exchangeObjectAtIndex:3 withObjectAtIndex:(self.applistArray.count-2)];
[self.applistArray exchangeObjectAtIndex:4 withObjectAtIndex:(self.applistArray.count-1)];
for (int i = 0; i < self.applistArray.count; i++) {
AppInformationCell *appInformationCell = [[AppInformationCell alloc] init];
appInformationCell.frame = CGRectMake(i * 80, 0, 80, 80);
[appInformationCell refreshWithData:[self.applistArray objectAtIndex:i]];
appInformationCell.tag = i+1;
[_myscrollView addSubview:appInformationCell];
if (appInformationCell.tag == 1) {
appInformationCell.transform=CGAffineTransformMakeScale(0.7f, 0.7f);
} else if (appInformationCell.tag == 2) {
appInformationCell.transform=CGAffineTransformMakeScale(0.8f, 0.8f);
} else if (appInformationCell.tag == 3) {
appInformationCell.transform=CGAffineTransformMakeScale(1.0f, 1.0f);
} else if (appInformationCell.tag == 4) {
appInformationCell.transform=CGAffineTransformMakeScale(0.8f, 0.8f);
} else if (appInformationCell.tag == 5) {
appInformationCell.transform=CGAffineTransformMakeScale(0.7f, 0.7f);
} else {
appInformationCell.transform=CGAffineTransformMakeScale(0.67f, 0.67f);
}
}
_myscrollView.contentOffset = CGPointMake(40, 0);
linshiInt = 0;