Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Custom View
- */
- class CustomView: UIView() {
- @IBOutlet weak var actionButton: UIButton!
- public var buttonAction: (() -> Void)?
- // init coder, frame
- private func initialize(){
- //...
- //=== actionButton
- self.actionButton.addTarget(self, action: #selector(self.actionButtonTouch(_:)), for: .touchUpInside)
- }
- @objc func actionButtonTouch(_ sender: UIButton) {
- buttonAction?()
- }
- }
- /*
- ViewController
- */
- func initContentView() {
- let customView = ...
- customView.buttonAction = { [weak self] in
- self?.x()
- let mainViewController = MainViewController()
- self?.navigationController?.pushViewController(mainViewController, animated: true)
- }
- }
Add Comment
Please, Sign In to add comment