Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mhijack/c9f084a102ba2bcd6475c31b25f5c005 to your computer and use it in GitHub Desktop.
Save mhijack/c9f084a102ba2bcd6475c31b25f5c005 to your computer and use it in GitHub Desktop.
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