Search code examples
ioscosmicmind

Comicmind Material Framework button event handler


I would just like to ask, how can I handle events of the Material Button using cosmicmind/Material? I currently have this code. Now, I want to do a function when user taps or clicked the button. Thank you!

fileprivate func prepareRaisedButton() {
        let button = RaisedButton(title: "Create an account", titleColor : .white)
        button.pulseColor = .white
        button.backgroundColor = Color.teal.base

        view.layout(button)
            .height(ButtonLayout.Raised.height)
            .top(18 * constant).horizontally(left : constant, right : constant)
    }

Solution

  • The method you want is inherited from UIControl:

    button.addTarget(self, action: #selector(tapButton), for: .touchUpInside)