scrollviews page分页实现方式

代码

buttonX = 0;
buttonW = 50;
buttonH = 20;
margin = (self.view.width - 5 * buttonW) / 6;
CGFloat ymargin = 17;
for (int i = 0; i < self.platformArr.count; i++) {
    YTBottomTitleButton *button = self.platformArr[i];
    buttonX = margin +  (i % 5 == 0 ? 0 : (buttonW + margin) * (i % 5)) + (i % 20 == 0 ? ZWScreenW * i / 20 : ZWScreenW * (i - i % 20) / 20);
    buttonY = i % 5 == 0 ? (i % 20 == 0 ? ymargin : ymargin + (buttonH + ymargin) * ((i % 20) / 5)) : buttonY;        
    button.frame = CGRectMake(buttonX, buttonY, buttonW, buttonH);
}

NSInteger offset = self.platformArr.count > 20 ? (self.platformArr.count % 20 == 0 ? self.platformArr.count / 20 : self.platformArr.count / 20 + 1) : 0;
self.platformScrollView.contentSize = CGSizeMake(offset * ZWScreenW, 0);
原文地址:https://www.cnblogs.com/jackyshan/p/5487155.html