로딩 애니메이션 변경
This commit is contained in:
parent
f018bd30e6
commit
550bf0c1c7
|
@ -8,57 +8,18 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LoadingView: View {
|
struct LoadingView: View {
|
||||||
@State var index = 0
|
|
||||||
|
|
||||||
@State var timer = Timer.publish(every: 0.35, on: .current, in: .common).autoconnect()
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color.primary.opacity(0.2)
|
Color.primary.opacity(0.2)
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
|
|
||||||
ZStack {
|
ZStack {
|
||||||
Image("loading_1")
|
ActivityIndicatorView()
|
||||||
.resizable()
|
|
||||||
.frame(width: 100, height: 100)
|
.frame(width: 100, height: 100)
|
||||||
.opacity(index == 0 ? 1.0 : 0.0)
|
|
||||||
|
|
||||||
Image("loading_2")
|
|
||||||
.resizable()
|
|
||||||
.frame(width: 100, height: 100)
|
|
||||||
.opacity(index == 1 ? 1.0 : 0.0)
|
|
||||||
|
|
||||||
Image("loading_3")
|
|
||||||
.resizable()
|
|
||||||
.frame(width: 100, height: 100)
|
|
||||||
.opacity(index == 2 ? 1.0 : 0.0)
|
|
||||||
|
|
||||||
Image("loading_4")
|
|
||||||
.resizable()
|
|
||||||
.frame(width: 100, height: 100)
|
|
||||||
.opacity(index == 3 ? 1.0 : 0.0)
|
|
||||||
|
|
||||||
Image("loading_5")
|
|
||||||
.resizable()
|
|
||||||
.frame(width: 100, height: 100)
|
|
||||||
.opacity(index == 4 ? 1.0 : 0.0)
|
|
||||||
}
|
}
|
||||||
.frame(width: 150, height: 150)
|
.frame(width: 150, height: 150)
|
||||||
.background(Color.white)
|
|
||||||
.cornerRadius(14)
|
|
||||||
.shadow(color: Color.primary.opacity(0.07), radius: 5, x: 5, y: 5)
|
|
||||||
.shadow(color: Color.primary.opacity(0.07), radius: 5, x: -5, y: -5)
|
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.onReceive(timer) { _ in
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
if index == 4 {
|
|
||||||
index = 0
|
|
||||||
} else {
|
|
||||||
index += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,3 +28,16 @@ struct LoadingView_Previews: PreviewProvider {
|
||||||
LoadingView()
|
LoadingView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ActivityIndicatorView: UIViewRepresentable {
|
||||||
|
func makeUIView(context: Context) -> some UIActivityIndicatorView {
|
||||||
|
let activityIndicator = UIActivityIndicatorView(style: .large)
|
||||||
|
activityIndicator.color = UIColor(hex: "80D8FF")
|
||||||
|
return activityIndicator
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateUIView(_ uiView: UIViewType, context: Context) {
|
||||||
|
uiView.startAnimating()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue