Files
self/app/ios/LottieView.swift
turnoffthiscomputer 21a1fe23a8 add mrz scan animation
2024-07-22 14:18:58 +02:00

42 lines
1.1 KiB
Swift

//
// LottieView.swift
// FreedomTools
//
// Created by Ivan Lele on 27.02.2024.
//
import Lottie
import SwiftUI
struct LottieView: UIViewRepresentable {
var animationFileName: String
let loopMode: LottieLoopMode
func updateUIView(_ uiView: UIViewType, context: Context) {}
func makeUIView(context: Context) -> some UIView {
let view = UIView(frame: .zero)
let animationView = LottieAnimationView(name: animationFileName)
animationView.loopMode = loopMode
animationView.contentMode = .scaleAspectFit
animationView.play()
animationView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(animationView)
NSLayoutConstraint.activate([
animationView.widthAnchor.constraint(equalTo: view.widthAnchor),
animationView.heightAnchor.constraint(equalTo: view.heightAnchor)
])
return view
}
}
#Preview {
LottieView(animationFileName: "passport", loopMode: .loop)
.frame(width: 300)
}