for a in 1..<5 {
print(a)
for b in 1...a {
print(b)
let mayView = UIView()
mayView.frame = CGRect(x: 80 * b, y: 40 * a, width: 65, height: 30)
if b == 2 && a == 3{
mayView.backgroundColor = UIColor.yellowColor()
}
else {
mayView.backgroundColor = UIColor.greenColor()
}
self.view.addSubview(mayView)
}
}
let any = ["姓名:", "性别:", "年龄:"]
for i in 0..<any.count {
let label = UILabel()
label.text = any[i]
label.frame = CGRect(x: 90, y: 45 * i, width: 200, height: 100)
self.view.addSubview(label)
}
网友评论