swift3.0 简单的九宫格

foriin0..<10{

letbtn = UIButton()

btn.backgroundColor = UIColor.red

letmargin =7

letcount =4

letrow = i / count

letcol = i % count

letw =140

leth =44

letx = col * (margin + w) +30

lety = row * (margin + h) +30

btn.frame = CGRect(x: x, y: y, width: w, height: h)

content.addSubview(btn)

}

你可能感兴趣的:(swift3.0 简单的九宫格)