1. 程式人生 > >【iOS開發系列】九宮格布局

【iOS開發系列】九宮格布局

使用 objc with div self. orm i++ back hab

/**
 *  這個盡管非常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];
    }
}

【iOS開發系列】九宮格布局