ruipfcosta / SwiftyWalkthrough

The easiest way to create a great walkthrough experience in your apps, powered by Swift.
MIT License
372 stars 47 forks source link

Button in customView #1

Open rafaelbletro opened 8 years ago

rafaelbletro commented 8 years ago

Hi, congratulations this is a vey good class.

I`m creating a subclass and inside has a button, i used your example of subclass to create mine subclass.

`

lazy var helpLabel: UILabel = self.makeHelpLabel()
lazy var titleLabel: UILabel = self.makeTitleLabel()
lazy var image: UIImageView = self.makeImage()
lazy var entendiBtn: UIButton = self.makeButton()

init() {
    super.init(frame: CGRectZero)
    self.userInteractionEnabled = true;

    addSubview(titleLabel)
    addSubview(helpLabel)
    addSubview(entendiBtn)

}

`

You know how i get touchevent on button? I test override the method hittest, but called two times the delegate.

   override internal func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {

        let currentView = self.entendiBtn
        let convertedPoint = currentView.convertPoint(point, fromView: self)

        if currentView.pointInside(convertedPoint, withEvent: event) {
            delegate?.willInteractWithView?(currentView)
            return currentView.hitTest(convertedPoint, withEvent: event)
        }

        return super.hitTest(point, withEvent: event)
    }
ruipfcosta commented 7 years ago

Hi @rafaelbletro, have a look at this section on the documentation. However, you can handle interactions with UIButton as usual (i.e. touchUpInside) if that's what you're trying to do.