1 |
efrain |
1 |
//
|
|
|
2 |
// LottieView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 7/12/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import SwiftUI
|
|
|
9 |
import Lottie
|
|
|
10 |
|
|
|
11 |
struct LottieView: UIViewRepresentable {
|
|
|
12 |
var name: String
|
|
|
13 |
var loopMode: LottieLoopMode = .playOnce
|
|
|
14 |
|
|
|
15 |
var animationView = AnimationView()
|
|
|
16 |
|
|
|
17 |
func makeUIView(context: UIViewRepresentableContext<LottieView>) -> UIView {
|
|
|
18 |
let view = UIView(frame: .zero)
|
|
|
19 |
|
|
|
20 |
animationView.animation = Animation.named(name)
|
|
|
21 |
animationView.contentMode = .scaleAspectFit
|
|
|
22 |
animationView.loopMode = loopMode
|
|
|
23 |
animationView.play()
|
|
|
24 |
|
|
|
25 |
animationView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
26 |
view.addSubview(animationView)
|
|
|
27 |
|
|
|
28 |
NSLayoutConstraint.activate([
|
|
|
29 |
animationView.heightAnchor.constraint(equalTo: view.heightAnchor),
|
|
|
30 |
animationView.widthAnchor.constraint(equalTo: view.widthAnchor)
|
|
|
31 |
])
|
|
|
32 |
|
|
|
33 |
return view
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieView>) {}
|
|
|
37 |
}
|