Is there any way to expand my lottie animation to a given frame.
I am currently using below modifiers, I am getting the correct height and width but my lottie is not filling that, only covering the height.
LottieView {
try await DotLottieFile.named("animationFileName")
}
.playing()
.resizable()
.animationSpeed(0.4)
.animationDidFinish({ _ in
isExpanded = false
})
.aspectRatio(contentMode: .fill)
.clipShape(.rect(cornerRadius: 24))
.frame(maxWidth: isPlaying ? .infinity : selectedFireFrame.width,
maxHeight: isPlaying ? .infinity : selectedFireFrame.height)
.position(x: isPlaying ? UIScreen.main.bounds.midX : selectedFireFrame.midX,
y: isPlaying ? UIScreen.main.bounds.midY : selectedFireFrame.midY)
.onAppear {
// Delay before starting the expansion
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { // some delay
withAnimation(.easeInOut(duration: 0.2)) {
isPlaying = true
}
}
}
I used .resizable() modifier and set the frame too.
Aman Jha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.