Skip to content

Instantly share code, notes, and snippets.

@kyungpyoda
Created April 27, 2021 06:57
Show Gist options
  • Save kyungpyoda/e5b0c78619911ab596504962e2bf60b8 to your computer and use it in GitHub Desktop.
Save kyungpyoda/e5b0c78619911ab596504962e2bf60b8 to your computer and use it in GitHub Desktop.
RxSwift custom LongPress gesture
import RxSwift
extension Reactive where Base: UIButton {
var longPress: Observable<Int> {
return controlEvent(.touchDown)
.flatMapLatest { _ in
Observable.timer(.milliseconds(500), scheduler: MainScheduler.instance)
.takeUntil(self.controlEvent(.touchUpInside))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment