Created
May 12, 2021 04:29
-
-
Save mhijack/c9f084a102ba2bcd6475c31b25f5c005 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ResponderViewController: UIViewController { | |
private var redView = UIView() | |
private var greenView = UIView() | |
private var blueView = UIView() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.subviews(redView.subviews(greenView).subviews(blueView)) | |
redView.height(300).width(300).centerVertically().centerHorizontally() | |
redView.backgroundColor = .red | |
greenView.height(150).width(150).centerVertically().centerHorizontally() | |
greenView.backgroundColor = .green | |
blueView.height(75).width(75).centerVertically().centerHorizontally() | |
blueView.backgroundColor = .blue | |
let tapRoot = UITapGestureRecognizer(target: self, action: #selector(didTapRoot)) | |
view.isUserInteractionEnabled = true | |
view.addGestureRecognizer(tapRoot) | |
let tapRed = UITapGestureRecognizer(target: self, action: #selector(didTapRed)) | |
redView.isUserInteractionEnabled = true | |
redView.addGestureRecognizer(tapRed) | |
} | |
@objc private func didTapRoot() { | |
print("Root") | |
} | |
@objc private func didTapRed() { | |
print("Red") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment