在stackoverflow中,仅显示2或3个按钮,即通过情节提要
答案 0 :(得分:1)
var consolebtn = [UIButton]()
var x = Int()
x = 0
@IBAction func pushButton(sender: UIButton) {
let btn = UIButton()
btn.frame = CGRect(x:x, y:10, width:10, height:10)
btn.setTitle("Button Title",for: .normal)
consolebtn.append(btn)
view.addSubview(btn)
x += 20 // 10 is width & 10 is gap between two button
}
答案 1 :(得分:0)