OC 九宫格布局

- (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];
    }
     
}

 

   

posted on 2015-06-19 15:58  奋进的闹钟  阅读(263)  评论(0编辑  收藏  举报

导航