The following code animates the size of an image as soon as it loads, it animates it from half of its size to its full size, but there is something I don't fully understand about the parameters in scaleFactor
.
Can someone explain the parameter inside the scaleEffect
modifier?
- How come it can take a Boolean parameter?
- How is it possible to enter a scale range
1.0 : 0.5
parameter? - What does the
?
do?
As far as I can see the scaleEffect
modifier only takes two parameters, a CGFloat
and a UnitPoint
.
struct ContentView: View {
@State private var scaleFactor = false
var body: some View {
VStack {
Image("top-image")
.scaleEffect(scaleFactor ? 1.0 : 0.5)
.animation(.easeInOut(duration: 1.0))
.onAppear() {
self.scaleFactor = true
}
}
}
}