首页 > 技术文章 > OC 九宫格布局

allanliu 2015-06-19 15:58 原文

- (void)jiugongge{
     
    NSArray *array =@[[UIColor cyanColor],[UIColor lightGrayColor],
                             [UIColor yellowColor],[UIColor purpleColor],
                             [UIColor blueColor],[UIColor greenColor],
                             [UIColor blackColor],[UIColor magentaColor],
                      [UIColor magentaColor]
                             ];
    for (int i=0; i<9; i++) {
         
       UIView *view = [[UIView alloc]initWithFrame:CGRectMake(i%3*50+100, i/3*50+100, 30, 30)];
        
        view.backgroundColor = array[i];
     
        [self.view addSubview:view];
    }
     
}

 

   

推荐阅读