iCarousel 第一个item的位置总是在中间位置?我想让他靠左边

 

问题描述:

图片描述

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view {
    
    if (!view) {
        view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 110, 110)];
    }
    view.backgroundColor = self.recommendDataArray[index];
    return view;
}

 

第 1 个答案:

iCarousel 有一个方法可以滚动到指定的 item 位置,视图加载完直接调用滚动到第2个或者第3个 item,第一个 item 的位置就靠左边了。

- (void)scrollToItemAtIndex:(NSInteger)index animated:(BOOL)animated;

var arr1 = [{ id: 1, name: 'a' }, { id: 2, name: 'b' }, { id: 3, name: 'c' }, { id: 4, ...