Closed Sajjon closed 4 years ago
If using custom inside the barButtonItem, maybe something like:
extension Reactive where Base: UIViewController {
public var leftBarButtonTapped: ControlEvent<Void> {
guard let button = self.base.navigationItem.leftBarButtonItem?.customView as? UIButton else { return ControlEvent(events: Observable.empty()) }
return button.rx.tap
}
public var rightBarButtonTapped: ControlEvent<Void> {
guard let button = self.base.navigationItem.rightBarButtonItem?.customView as? UIButton else { return ControlEvent(events: Observable.empty()) }
return button.rx.tap
}
}
credit goes to @oscarsilver
It would not work if the left bar button is not a custom button. RxCocoa already supports UIBarButtonItem+Rx so you may use that.
Hi! Would it be possible to extend RxViewController tap events of the optional
leftBarButtonItem
andrightBarButtonItem
?It would be awesome to listen to these!