【发布时间】:2016-08-09 22:31:48
【问题描述】:
如何在数组中的循环中为 UIButton 分配唯一标签:
var buttonArray: NSMutableArray = ["one", "two", "Three"] // it is a mutable array but for illustration purposes only I put this....
for btnName in buttonArray {
let button = UIButton(frame: CGRectMake(0,0,100,100))
button.layer.masksToBounds = true
button.layer.cornerRadius = 20
button.setTitle("\(btnName)", forState: UIControlState.Normal)
//button.tag = ??????
print(button.tag)
}
【问题讨论】: