Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对 RxSwift 和 RxCocoa 很陌生。我想使用 RxCocoa 将图像设置为 UIButton。
settingButton.rx.image(for: .normal).onNext(UIImage.init(named: "closeButton"))
任何人都知道如何将图像设置为 UIButton?我做得对吗?
我不建议您被动地设置按钮的图像。如果您没有任何特殊原因这样做,请以正常(必要)方式进行:
settingButton.setImage(UIImage.init(named: "closeButton"), for: .normal)
这是你如何被动地做到这一点,不需要asObserver和东西:
asObserver
button.rx.image().onNext(UIImage.init(named: "closeButton"))