0
// This button has different images with for selection and no selection which I configured in storyboard different images for two states.
@IBOutlet weak var selectedRestarunt: UIButton!
// I am binding isSelected state like this which is working when user taps on button.
selectedRestarunt.rx.tap.scan(false) { lastState, _ in
return !lastState
}
現在我有一個案例我手動標記isSelected
沒有水龍頭。我該如何綁定UIButton.isSelectable與RXSwift
selectedRestarunt.isSelected = false/true
這應該不會觸發現有映射。 這應該以某種方式映射,以便我需要根據isSelected
狀態進行一些操作。 有人可以解釋我怎麼能做到這一點?
我想你應該爲'isSelected'屬性編寫自己的包裝器。參見:https://github.com/ReactiveX/RxSwift/blob/master/RxCocoa/iOS/UIButton%2BRx.swift –