So I’ve a picture whose width is larger than display width. And I wanna transfer it throughout the display in horizontal path. Presently, I’m able to animate it seamlessly however it’s a steady animation, and I would like it to be in intervals. So proper now, complete picture is being animated in 10 seconds with out stopping. What I would like is that picture to animate however with small breaks and gaps. (Could also be picture animate to left with 100 pts, then cease, then once more proceed transferring in direction of left). I’ve tried taking part in with offset however it is not working. Right here is the present video Under is my code.
struct AnimatingHorizontalImageView: View {
@State var animate: Bool = false
let animation: Animation = Animation.linear(period: 10.0).repeatForever(autoreverses: false)
let width = UIScreen.predominant.bounds.width
let top = UIScreen.predominant.bounds.top
var physique: some View {
HStack(spacing: -1) {
Picture(.banner)
.resizable()
.scaledToFill()
.body(top: 210)
Picture(.banner)
.resizable()
.scaledToFill()
.body(width: width,top: 210, alignment: .main)
}
.body(width: width, top: 210,
alignment: animate ? .trailing : .main)
.onTapGesture {
print(width)
}
.ignoresSafeArea()
.onAppear {
withAnimation(animation) {
animate.toggle()
}
}
}
}