struct ShakeEffect: GeometryEffect {
var times: CGFloat = 0
let amplitude: CGFloat = 10
// โญ๏ธ ๐
ฟ๏ธ Animatable
var animatableData: CGFloat {
get { times }
set { times = newValue }
}
// โญ๏ธ ๐
ฟ๏ธ GeometryEffect
func effectValue(size: CGSize) -> ProjectionTransform {
ProjectionTransform(CGAffineTransform(
translationX: sin(times * .pi * 2) * amplitude, y: 0
))
}
}
โฉ
โฉ (struct) - 3x3 matrix.
โฉ (protocol)
- required instance method.
SwiftUI Lab โฉ Advanced SwiftUI Animations โฉ