zoukankan      html  css  js  c++  java
  • scrollview技巧

    一行

        CGFloat buttonX = 0;
        CGFloat buttonY = 25;
        CGFloat buttonW = 37;
        CGFloat buttonH = 60;
        CGFloat margin = (self.view.width - 6 * buttonW) / 7;
        for (int i = 0; i < self.countryArr.count; i++) {
            YTBottomTitleButton *button = self.countryArr[i];
            buttonX = margin + (buttonW + margin) * i;
            button.frame = CGRectMake(buttonX, buttonY, buttonW, buttonH);
        }
        self.countryScrollView.contentSize = CGSizeMake(self.countryArr.count * (buttonW + margin) + margin, 0);
    

    两行

        buttonX = 0;
        buttonY = 25;
        buttonW = 50;
        buttonH = 20;
        NSInteger viewCount = 5;//一行view数量
        margin = (self.view.width - viewCount * buttonW) / 6;//左右间距
        CGFloat ymargin = 17;//上下间距
        NSInteger pageViewCount = 0;//一页view数量
        if (self.view.width > 320) {//iPhone6 or later
            pageViewCount = 20;
        }
        else {
            pageViewCount = 15;
        }
        for (int i = 0; i < self.platformArr.count; i++) {
            YTBottomTitleButton *button = self.platformArr[i];
            buttonX = margin +  (i % viewCount == 0 ? 0 : (buttonW + margin) * (i % viewCount)) + (i % pageViewCount == 0 ? ZWScreenW * i / pageViewCount : ZWScreenW * (i - i % pageViewCount) / pageViewCount);
            buttonY = i % viewCount == 0 ? (i % pageViewCount == 0 ? ymargin : ymargin + (buttonH + ymargin) * ((i % pageViewCount) / viewCount)) : buttonY;
            
            button.frame = CGRectMake(buttonX, buttonY, buttonW, buttonH);
        }
        
        NSInteger offset = self.platformArr.count > pageViewCount ? (self.platformArr.count % pageViewCount == 0 ? self.platformArr.count / 20 : self.platformArr.count / pageViewCount + 1) : 0;
        self.platformScrollView.contentSize = CGSizeMake(offset * ZWScreenW, 0);
  • 相关阅读:
    js 生成32位UUID方法
    win10把控制声音改成和win7一样
    jQuery.inArray()方法
    在eclipse中安装activiti插件
    关于NOIP运输计划一题几种思路和若干种做法的研究
    该博客停止更新
    [CTSC2010]产品销售
    roi 学习轨迹
    「PA 2019」Szprotki i szczupaki
    LOJ576签到游戏
  • 原文地址:https://www.cnblogs.com/jackyshan/p/5591558.html
Copyright © 2011-2022 走看看