Код: Выделить всё
import SwiftUI
struct CustomAnimation: ViewModifier {
@State private var isAnimated: Bool = false
func body(content: Content) -> some View {
content
.phaseAnimator([true, false], trigger: self.isAnimated) { view, phase in
view
.scaleEffect(phase ? 1 : 1.2)
}
.onTapGesture {
self.isAnimated.toggle()
}
}
}
#Preview {
@Previewable @State var isPresented: Bool = true
VStack {
Button {
isPresented = true
} label: {
Text("show sheet")
}
}
.sheet(isPresented: $isPresented) {
VStack {
Spacer()
Text("my animated text")
.modifier(CustomAnimation())
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... esentation