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 –