Loader.swift 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // Loader.swift
  3. // fiveConstant
  4. //
  5. // Created by 李建 on 2023/1/14.
  6. //
  7. import SwiftUI
  8. struct Loader: View {
  9. @State var spinCircle = false
  10. var body: some View {
  11. ZStack {
  12. Rectangle().frame(width:160, height: 135).background(Color.black).cornerRadius(8).opacity(0.6).shadow(color: .black, radius: 16)
  13. VStack {
  14. Circle()
  15. .trim(from: 0.3, to: 1)
  16. .stroke(Color.white, lineWidth:3)
  17. .frame(width:40, height: 40)
  18. .padding(.all, 8)
  19. .rotationEffect(.degrees(spinCircle ? 0 : -360), anchor: .center)
  20. .animation(Animation.linear(duration: 0.6).repeatForever(autoreverses: false))
  21. .onAppear {
  22. self.spinCircle = true
  23. }
  24. Text("加载中...").foregroundColor(.white)
  25. }
  26. }
  27. }
  28. }
  29. struct Loader_Previews: PreviewProvider {
  30. static var previews: some View {
  31. Loader()
  32. }
  33. }