UIView+Rx.swift 671 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // UIView+Rx.swift
  3. // SwiftBilibili
  4. //
  5. // Created by 罗文 on 2021/2/1.
  6. // Copyright © 2021年 罗文. All rights reserved.
  7. //
  8. import UIKit
  9. import RxCocoa
  10. import RxSwift
  11. extension Reactive where Base: UIView {
  12. var setNeedsLayout: Binder<Void> {
  13. return Binder(self.base) { view, _ in
  14. view.setNeedsLayout()
  15. }
  16. }
  17. var backgroundColor: Binder<UIColor?> {
  18. return Binder(self.base) { view,color in
  19. view.backgroundColor = color
  20. }
  21. }
  22. var borderColor: Binder<UIColor?> {
  23. return Binder(self.base) { view,color in
  24. view.borderColor = color ?? .clear
  25. }
  26. }
  27. }