zoukankan      html  css  js  c++  java
  • 根据输入的个数,打印每行做多输出3个的for循环

    #define Screen_width  [[UIScreen mainScreen] bounds].size.width

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        //要显示的个数

        int How = 11;

    //    要显示的列数

        int lie = 4;

    //    中间的间隔

        int jiange = 10;

        //每行最多3个,根据个数看需要显示几行

        int row;

        if (How%lie>0) {

            row = How/lie+1;

            

        }else{

            row = How/lie;

        }

        //   根据输入的个数打印一个3列的数据    外控制行  内控制列

        int xZhou ;

        int yZhou ;

        for (int i = 0; i < row; i++) {

            yZhou = (Screen_width-(lie+1)*jiange)/lie*i+i*jiange+jiange;

            

            for(int y = 0; y< lie; y++){

                xZhou = (Screen_width-(lie+1)*jiange)/lie*y+y*jiange+jiange;

                

                if(i*lie+y+1 == How){

                    break;

                }else{

                    

                    printf("x轴:%d   y轴:%d",xZhou,yZhou);

                    UIButton *addPhotoButton = [[UIButton alloc]initWithFrame:CGRectMake(xZhou, yZhou, (Screen_width-(lie+1)*jiange)/lie, (Screen_width-(lie+1)*jiange)/lie)];

                    addPhotoButton.backgroundColor = [UIColor greenColor];

                    [self.view addSubview:addPhotoButton];

                    printf("*");

                }

                

            }

            printf(" ");

        }

        

        // Do any additional setup after loading the view, typically from a nib.

    }

  • 相关阅读:
    HTML 基础学习笔记
    使用python访问网络上的数据
    linux上创建ftp服务器下载文件///使用AWS服务器作为代理,下载sbt相关的包
    jquery,字符串转json对象,json对象转字符串
    vue渲染过程的{{xxx}}显示的解决办法
    v-model select 选中值后自动改变vue实例中的属性值
    uniapp华为手机真机运行方法
    获取本机mac地址
    编码Code
    int型比较大小
  • 原文地址:https://www.cnblogs.com/AlienY/p/4676887.html
Copyright © 2011-2022 走看看