Просмотр анимации лотереи:
Код: Выделить всё
import SwiftUI
import Lottie
struct LottieIconAnimation: View {
@State var fileName: String
var lottieAnimation: LottieAnimation? { LottieAnimation.named(fileName, subdirectory: AnimationConstant.animationResourcePath) }
var body: some View {
VStack {
LottieView(animation: lottieAnimation)
.animationSpeed(AnimationConstant.animationSpeed)
.playing()
.frame(width: 50, height: 50)
}
}
}
#Preview {
LottieIconAnimation(fileName: "TrolleyFull")
}

Круговая диаграмма просмотр:
Код: Выделить всё
struct PieChart: View {
@State var elements: [ChartElement]
@State var donutCenterText = ""
@State private var selectedCount: Int?
@State private var selectedElement: ChartElement?
var body: some View {
Chart(elements, id: \.id) { element in
SectorMark(
angle: .value("Sales", element.value),
innerRadius: .ratio(0.618),
outerRadius: selectedElement?.icon == element.icon ? 175 : 150,
angularInset: 1.5
)
.cornerRadius(10)
.foregroundStyle(element.color.gradient)
.annotation(position: .overlay) {
VStack {
LottieIconAnimation(fileName: element.icon)
}
.frame(maxWidth: 50, maxHeight: 50)
.border(.black)
}
}
}
}

Что такое что происходит с анимацией?
Подробнее здесь: https://stackoverflow.com/questions/793 ... annotation