Parallax Effect in iOS 17
We can easily get the parallax effect from iOS 17 with just a few lines of code
1
2
3
4
5
6
7
8
9
10
11
12
13
VStack {
ZStack {
Image(imageName)
.resizable()
.scaledToFill()
.scrollTransition(axis: .horizontal) { content, phase in
content
.offset(x: phase.isIdentity ? 0 : phase.value * -250)
}
}
.containerRelativeFrame(.horizontal)
.clipShape(RoundedRectangle(cornerRadius: 36))
}