如何使用 RxCocoa 将图像设置为 UIButton
How to set image to UIButton by using RxCocoa
我对 RxSwift 和 RxCocoa 还很陌生。我想使用 RxCocoa 将图像设置为 UIButton。
settingButton.rx.image(for: .normal).onNext(UIImage.init(named: "closeButton"))
有人知道如何将图像设置为 UIButton 吗?我做得对吗?
我不建议您被动地设置按钮的图像。如果您没有任何特殊原因这样做,请按照正常(命令式)方式进行:
settingButton.setImage(UIImage.init(named: "closeButton"), for: .normal)
这里是你如何做反应,不需要 asObserver
和东西:
button.rx.image().onNext(UIImage.init(named: "closeButton"))
我对 RxSwift 和 RxCocoa 还很陌生。我想使用 RxCocoa 将图像设置为 UIButton。
settingButton.rx.image(for: .normal).onNext(UIImage.init(named: "closeButton"))
有人知道如何将图像设置为 UIButton 吗?我做得对吗?
我不建议您被动地设置按钮的图像。如果您没有任何特殊原因这样做,请按照正常(命令式)方式进行:
settingButton.setImage(UIImage.init(named: "closeButton"), for: .normal)
这里是你如何做反应,不需要 asObserver
和东西:
button.rx.image().onNext(UIImage.init(named: "closeButton"))