Questions tagged [swiftui-animation]

228 questions
3
votes
1 answer

SwiftUI Animation onLongPressGesture(minimumDuration: 0.5) automatically starts

I've created a circular button which I specified to show scale animation on .onLongPressGesture(minimumDuration: 0.5) the code is bellow: struct PlayerTouch: View { @State private var animationAmount: CGFloat = 1 @State var animationEffect =…
3
votes
1 answer

SwiftUI - How to limit the scope of animation to only the onAppear Transition

I'm new to SwiftUI and working through some sample projects to get the hang of it and I'm getting stuck on limiting the scope of the animation I set for the .transition for an AnimationModifier so it only impacts the animation of the transition and…
got2jam
  • 515
  • 5
  • 16
3
votes
1 answer

Understanding scaleEffect in SwiftUI

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…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
3
votes
2 answers

SwiftUI Transitions of Conditional Child Views

I'm trying to understand and experiment with swiftUI view transitions and could use some insight into why the following does not work the way I expect: struct ContentView: View { @State private var showOverlay: Bool = false var body: some View { …
orion
  • 354
  • 1
  • 13
2
votes
0 answers

Anchor a portion of a SwiftUI view during animation in an NSWindow

In the following code, I have a simple button that toggles the appearance of a rectangle between two elements in a VStack. When this toggle happens, the enclosing NSWindow changes size immediately and then the contents changes with the animation. A…
jnpdx
  • 45,847
  • 6
  • 64
  • 94
2
votes
0 answers

Swift / SwiftUI - State variable isn't updated inside switch statement?

I'm having trouble creating transitions that properly emulate iOS navigation transitions. Different transitions should play depending on whether the user is navigating "forward" or "backward", but it seems like the view inside my switch statement…
George B
  • 918
  • 3
  • 15
  • 24
2
votes
1 answer

New NavigationStack in SwiftUI transition, how to change from the default slide to custom or appear?

I have NavigationStack with its own navigation links, for iOS16 development. How to change the default slide transition to appear or a custom transition? Also do you apply the transition on the NavigationStack or on the NavigationLink? This is my…
2
votes
1 answer

SwiftUI .searchable new view

I am creating an app and I am using .searchable for my home view, but once it is clicked, I want it to bring up a new view where results of what is being searched is shown, and once the cancel button is clicked goes back to the home view. I…
2
votes
1 answer

How can I apply individual transitions to children views during insertion and removal in SwiftUI?

I have a container view that contains multiple child views. These child views have different transitions that should be applied when the container view is inserted or removed. Currently, when I add or remove this container view, the only transition…
Mattijs
  • 195
  • 2
  • 3
  • 12
2
votes
1 answer

Hero animation not working in List when setting row's id dynamically

Recently ran into an issue trying to perform Hero animation using matchedGeometryEffect in SwiftUI. My issue is that setting id for matchedGeometryEffect effect dynamically isn't working as expected. This is what I have so far: import…
rdev
  • 148
  • 7
2
votes
1 answer

SwiftUI withAnimation doesn't start until view appears

I have two views in a TabView, which are Page1 and Page2. The two pages have the same view in common: AnimatingText. Page2 has an additional button that starts the animation of AnimatingText. When I tap the button in Page2, I expected the animation…
shinhong
  • 406
  • 4
  • 13
2
votes
2 answers

Transitions not working inside NavigationView

I am trying to navigate between two views without a NavigationLink. Here is the code: import SwiftUI struct NextView: View { @State var text = "" @Binding var displayView: Bool var body: some View { // 3 …
Laura Corssac
  • 1,217
  • 1
  • 13
  • 23
2
votes
0 answers

SiwftUI nested buttons, child tap triggers parent animation

I have been looking around but couldn't find the solution so lets hope someone can help me. I have a ScrollView with a LazyVStack in it. Then I have a list of 'cells'. Simplified it looks something like Button(action: { ... }) { HStack { …
Saren Inden
  • 3,450
  • 4
  • 32
  • 45
2
votes
1 answer

Why animation is speeding up after changing a property? SwiftUI

I tried to do this Particle Animation and wanted to change the color property. Every time I do it, the animation speeds up. How can I prevent this from happening? I'm kinda new to this, so is there a better approach? This is my Emitter struct…
Andrea
  • 23
  • 3
2
votes
2 answers

How to animate a view in a circular motion using its real-time position coordinates?

I'm currently working on a SwiftUI project, and in order to detect intersections/collisions, I need real-time coordinates, which SwiftUI animations cannot offer. After doing some research, I came across a wonderful question by Kike regarding how to…
PGCodes
  • 23
  • 3
1 2
3
15 16