Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SwiftUI
- import UIKit
- struct ActivityIndicator : UIViewRepresentable {
- var animating: Bool
- var hidesWhenStopped = true
- var style: UIActivityIndicatorView.Style = UIActivityIndicatorView.Style.medium
- func makeUIView(context: Context) -> UIActivityIndicatorView {
- let control = UIActivityIndicatorView()
- updateValues(for: control)
- return control
- }
- func updateValues(for uiView: UIActivityIndicatorView) {
- uiView.style = style
- uiView.hidesWhenStopped = hidesWhenStopped
- if animating {
- uiView.startAnimating()
- } else {
- uiView.stopAnimating()
- }
- }
- func updateUIView(_ uiView: UIActivityIndicatorView, context: Context) {
- updateValues(for: uiView)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement