iOS 실전 (swift)/UI 커스텀(프로그래밍적 접근)
[iOS - UI Custom] 16. TapGuestureRecognizer(탭 제스쳐) (programmatically)
jake-kim
2020. 5. 5. 19:41
제스쳐 생성 및 등록, 6~7번라인
|
1
2
3
4
5
6
7
8
9
10
11
12
|
// ViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
/// view에 tap제서쳐 등록
let tap = UITapGestureRecognizer(target: self, action: #selector(myPrint(_:)))
view.isUserInteractionEnabled = true // 없으면 동장하지 않음 view.addGestureRecognizer(tap)
}
@objc func myPrint(_ sender: Any) {
print("tap!")
}
|
