创建九宫格:
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];
}
swift版本:
for i in 0...3 {
print("取余是:\(i%3)")
}
for i in 0...3 {
print("取整是:\(i/3)")
}
控制台打印如下:
作者:稻草人11223
标签:20,int,九宫格,60,bun,print From: https://blog.51cto.com/u_13188203/7201367