- (void)createCoinWalletView{
self.coinAssetArr = [NSMutableArray array];
//模拟数据
for (int i = 0; i < 3; i++) {
[self.coinAssetArr addObject:@""];
}
float width = self.coinAssetViewScrollView.frame.size.width -10;
float height = self.coinAssetViewScrollView.frame.size.height - 10;
margin = 5;
for (int i = 0; i < self.coinAssetArr.count; i++) {
MyCoinAssetView * view = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([MyCoinAssetView class])
owner:nil
options:nil].firstObject;
view.frame = CGRectMake(margin*(2*i+1) + i * width, margin, width, height);
[self.coinAssetViewScrollView addSubview:view];
}
self.automaticallyAdjustsScrollViewInsets = false;
self.coinAssetViewScrollView.delegate = self;
self.coinAssetViewScrollView.pagingEnabled = YES;
// self.coinAssetViewScrollView.bounces = NO;
self.coinAssetViewScrollView.showsHorizontalScrollIndicator = NO;
// self.coinAssetViewScrollView.contentSize = CGSizeMake(ABS(width * self.coinAssetArr.count + margin * (self.coinAssetArr.count + 1)), height);
self.coinAssetViewScrollView.contentSize = CGSizeMake(ABS(width+2*margin)*self.coinAssetArr.count, height);
self.pageControl.numberOfPages = self.coinAssetArr.count;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
DLog(@"%f",scrollView.contentOffset.x);
int index = fabs(scrollView.contentOffset.x)/(self.coinAssetViewScrollView.frame.size.width -10 * self.coinAssetArr.count + margin * (self.coinAssetArr.count + 1)) ;
self.pageControl.currentPage = index;
}
网友评论