【发布时间】:2019-07-10 12:14:47
【问题描述】:
我目前有一个带有自定义单元格的表格,其中包含一个按钮和一个标签。一切正常,标签显示产品名称,按钮响应按钮点击。
我希望能够为点击按钮的行/单元格的宽度设置动画。
这是我目前拥有的代码...
主视图控制器:
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reusableCell", for: indexPath) as! CustomCell
let data = items[indexPath.row]
cell.displayProductName.text = data.productName
cell.buttonAction = { sender in
print("Button tapped...")
}
return cell
}
}
自定义单元格
class CustomCell: UITableViewCell {
var buttonAction: ((UIButton) -> Void)?
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
@IBAction func activeInactive(_ sender: UIButton) {
self.buttonAction?(sender)
}
}
表格视图
如何为点击按钮的行的宽度设置动画?
【问题讨论】:
标签: ios swift uitableview uianimation