Skip to content

Instantly share code, notes, and snippets.

@rtking1993
Created January 31, 2018 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtking1993/acba1a35650568e95ef572084c86c260 to your computer and use it in GitHub Desktop.
Save rtking1993/acba1a35650568e95ef572084c86c260 to your computer and use it in GitHub Desktop.
Instantiating a custom UIView
import UIKit
// MARK: TestViewController
class TestViewController: UIViewController {
// MARK: Outlets
@IBOutlet var testView: TestView!
// MARK: View Methods
override func viewDidLoad() {
super.viewDidLoad()
testView.delegate = self
}
}
// MARK: TestViewDelegate Methods
extension TestViewController: TestViewDelegate {
func testView(_ testView: TestView, didSelect button: UIButton) {
guard let buttonText = button.titleLabel?.text else {
return
}
print("\(buttonText) pressed")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment