美文网首页
UI实现九宫格界面的搭建(08-03)

UI实现九宫格界面的搭建(08-03)

作者: Hilarylii | 来源:发表于2017-08-03 20:09 被阅读0次
- (void)viewDidLoad {
    [super viewDidLoad];
    
    for (int i = 0 ; i<5; i++) {
        for (int j = 0 ; j<8; j++) {
            CGFloat y = self.view.frame.size.height/8;
            CGFloat  x = self.view.frame.size.width/5;
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x*i, y*j, x, y)];
            int r = arc4random() % 256;
            int g = arc4random() % 256;
            int b = arc4random() % 256;
            label.backgroundColor = [UIColor colorWithRed:r / 255.f green:g / 255.f blue:b / 255.f alpha:1.0];
            [self.view addSubview:label];
            
        }
    }
    
}

相关文章

网友评论

      本文标题:UI实现九宫格界面的搭建(08-03)

      本文链接:https://www.haomeiwen.com/subject/foqmlxtx.html