iOS-UITabVIew Cell 添加 switf
作者:
久百一 | 来源:发表于
2019-12-21 20:02 被阅读0次 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let Identifier = "item_default"
let cell = tableView.dequeueReusableCell(withIdentifier: Identifier, for: indexPath)
cell.imageView?.image = UIImage(named: "fenlei")
// 添加开关按钮
var switf = UISwitch(frame: .zero)
switf.setOn(false, animated: true)
switf.tag = indexPath.row
switf.addTarget(self, action: #selector(self.switfChange(_:)), for: .valueChanged)
cell.accessoryView = switf
return cell
}
@objc func switfChange(_ sender:UISwitch!){
print("Select SwiftChange isOn = \(sender.isOn) index = \(sender.tag)")
}
本文标题:iOS-UITabVIew Cell 添加 switf
本文链接:https://www.haomeiwen.com/subject/ulzgnctx.html
网友评论