【iOS开发系列】九宫格布局

/**
 *  这个尽管非常easy,算是一个小技巧,可是碰到了就记录下来吧.积跬步,致千里嘛.
 */
- (void)scratchableLatex
{
    for (int i=0; i<9; i++)
    {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(i%3*100+50, i/3*100+50, 50, 50)];
        
        /* 当然为了区分,能够使用随机色 */
        view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1];
        
        [self.view addSubview:view];
    }
}

posted @ 2017-05-31 08:01  cxchanpin  阅读(179)  评论(0编辑  收藏  举报