SwiftyWalkthrough
SwiftyWalkthrough copied to clipboard
Button in customView
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)
}
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.