How to add click action on UIButton in iOS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | private lazy var setBtn: UIButton = { let btn = UIButton() btn.addTarget(self, action: #selector(setBtnTap), for: .touchUpInside) return btn }() @objc func setBtnTap() { print("setBtnTap") } private lazy var setBtn: UIButton = { let btn = UIButton() btn.addTarget(self, action: #selector(setBtnTap(_:)), for: .touchUpInside) return btn }() @objc func setBtnTap(_ sender: UIButton) { print("setBtnTap") } | cs |
12~22번째 줄 : 버튼을 클릭해야 하는 경우입니다.
1~10th line: This is the case you don't need to get button you clicked
12~22th line: This is the case you need to get button you clicked
댓글 없음:
댓글 쓰기