📜  活动指示器 swiftui - Swift 代码示例

📅  最后修改于: 2022-03-11 15:00:59.159000             🧑  作者: Mango

代码示例1
struct ActivityIndicator: UIViewRepresentable {

    @Binding var isAnimating: Bool
    let style: UIActivityIndicatorView.Style

    func makeUIView(context: UIViewRepresentableContext) -> UIActivityIndicatorView {
        return UIActivityIndicatorView(style: style)
    }

    func updateUIView(_ uiView: UIActivityIndicatorView, context: UIViewRepresentableContext) {
        isAnimating ? uiView.startAnimating() : uiView.stopAnimating()
    }
}

//Usage...
ActivityIndicator(isAnimating: .constant(true), style: .large)