九宫格

    for (int i = 0; i < 4; i++) {
        int a = 50 + i % 3 * 60 + i % 3 * 20;
        int b = 50 + i / 3 * 60 + i / 3 * 20;
        
        UIButton * bun = [UIButton buttonWithType:UIButtonTypeCustom];
        
        bun.frame = CGRectMake(a, b, 60, 60);
        bun.backgroundColor = [UIColor redColor];
        [self.view addSubview:bun];
    }

你可能感兴趣的:(九宫格)