Вопрос о проектах, созданных до xcode12…
fileprivate func createCell0() -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCell.CellStyle.default, reuseIdentifier: "cell0")
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.systemFont(ofSize: 18, weight: .light)
label.numberOfLines = 2
label.text = "label"
let repaySwitch = UISwitch(frame: CGRect(x: 0, y: 0, width: 47, height: 31))
repaySwitch.addTarget(self, action: #selector(repaySwitchAction(sender: )), for: .valueChanged)
repaySwitch.translatesAutoresizingMaskIntoConstraints = false
repaySwitch.widthAnchor.constraint(equalToConstant: 49).isActive = true
let stackView = UIStackView()
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .horizontal
stackView.distribution = .fill
stackView.addArrangedSubview(label)
stackView.addArrangedSubview(repaySwitch)
stackView.alignment = .center
cell.addSubview(stackView)
stackView.leftAnchor.constraint(equalTo: cell.leftAnchor, constant: 16).isActive = true
stackView.rightAnchor.constraint(equalTo: cell.rightAnchor, constant: -16).isActive = true
stackView.topAnchor.constraint(equalTo: cell.topAnchor, constant: 8).isActive = true
stackView.bottomAnchor.constraint(equalTo: cell.bottomAnchor, constant: -8).isActive = true
stackView.heightAnchor.constraint(equalToConstant: 44).isActive = true
return cell
}
@objc func repaySwitchAction(sender: UISwitch) {
print(#function)
}
не робит )))