Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import SwiftUI
  2. import UIKit
  3.  
  4. struct ActivityIndicator : UIViewRepresentable {
  5. var animating: Bool
  6. var hidesWhenStopped = true
  7. var style: UIActivityIndicatorView.Style = UIActivityIndicatorView.Style.medium
  8.  
  9. func makeUIView(context: Context) -> UIActivityIndicatorView {
  10. let control = UIActivityIndicatorView()
  11.  
  12. updateValues(for: control)
  13.  
  14. return control
  15. }
  16.  
  17. func updateValues(for uiView: UIActivityIndicatorView) {
  18. uiView.style = style
  19. uiView.hidesWhenStopped = hidesWhenStopped
  20. if animating {
  21. uiView.startAnimating()
  22. } else {
  23. uiView.stopAnimating()
  24. }
  25. }
  26.  
  27. func updateUIView(_ uiView: UIActivityIndicatorView, context: Context) {
  28. updateValues(for: uiView)
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement