123456789101112131415161718192021222324252627 |
- //
- // ActivityIndicator.swift
- // naiyoup
- //
- // Created by C Auto on 2021/5/30.
- //
- import SwiftUI
- struct ActivityIndicator: UIViewRepresentable {
-
- typealias UIView = UIActivityIndicatorView
- var isAnimating: Bool
- var configuration = { (indicator: UIView) in }
- func makeUIView(context: UIViewRepresentableContext<Self>) -> UIView { UIView() }
- func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<Self>) {
- isAnimating ? uiView.startAnimating() : uiView.stopAnimating()
- configuration(uiView)
- }
- }
- extension View where Self == ActivityIndicator {
- func configure(_ configuration: @escaping (Self.UIView)->Void) -> Self {
- Self.init(isAnimating: self.isAnimating, configuration: configuration)
- }
- }
|