Skip to content

Instantly share code, notes, and snippets.

@sagaya
Last active January 21, 2019 17:18
Show Gist options
  • Save sagaya/d1a4d88c804e430ab529fa53c1d4cd45 to your computer and use it in GitHub Desktop.
Save sagaya/d1a4d88c804e430ab529fa53c1d4cd45 to your computer and use it in GitHub Desktop.
using_generic_controller
class TestViewController: BaseController<OriginalView> {
}
class TestBaseView: BaseView {
public weak var buttonActionDelegate: MyViewActionDelegate?
private let button: UIButton = {
let button = UIButton(frame: .zero)
button.setTitle("View Works", for: .normal)
button.setTitleColor(.white, for: .normal)
button.setTitleColor(.gray, for: .highlighted)
button.backgroundColor = .black
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()
override func setupView() {
super.setupView()
addSubview(button)
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: centerXAnchor),
button.widthAnchor.constraint(equalToConstant: 100),
button.heightAnchor.constraint(equalToConstant: 50),
button.centerYAnchor.constraint(equalTo: centerYAnchor)
])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment