Questions tagged [swiftui-animation]
228 questions
21
votes
2 answers
This SwiftUI animation should only fade out. Why does it move to the right?
I'm having a hard time understanding why this happens. I reduced the problem to its minimum expression.
I have a single Text view, that when removed, should just fade out. The .transition(.opacity) has been added for clarity only. It should not be…

kontiki
- 37,663
- 13
- 111
- 125
18
votes
2 answers
SwiftUI - Animate view transition and position change at the same time
I have a yellow container with a green view inside. I want to move the container while also hiding/showing the inner green view, with an animation. Currently, I'm using .offset for the movement, and an if statement for the green view's…

aheze
- 24,434
- 8
- 68
- 125
18
votes
2 answers
How can I reverse the slide transition for a SwiftUI animation?
I'm working on a sequence of screens that should change on a button press and should slide in/out from right to left.
Everything is working nicely except the .slide transition makes it move in from the leading edge and move out to the trailing edge.…

noranraskin
- 1,127
- 8
- 17
9
votes
3 answers
SwiftUI - Sliding Text animation and positioning
On my journey to learn more about SwiftUI, I am still getting confused with positioning my element in a ZStack.
The goal is "simple", I wanna have a text that will slide within a defined area if the text is too long.
Let's say I have an area of 50px…

Oleg G.
- 550
- 5
- 25
8
votes
1 answer
How to animate dynamic List sorting with SwiftUI and CoreData (@FetchRequest)
I have a list that displays a CoreData FetchRequest, and I have a Picker that changes how the list is sorted. The current way I implemented this looks like:
struct ParentView: View {
enum SortMethod: String, CaseIterable, Identifiable {
…

Dovizu
- 405
- 3
- 13
7
votes
2 answers
SwiftUI Confetti Animation
Note: I solved the issue. If you are interested in the animation, I created a package with SPM and is available on https://github.com/simibac/ConfettiSwiftUI
So I am trying to create a confetti animation in SwiftUI. This is what I have so far:
This…

simibac
- 7,672
- 3
- 36
- 48
6
votes
0 answers
macOS NavigationStack use push and pop animation
how to set the Push / Pop animation in macOS for a NavigationStack ? as currently there is no animation and i want to push / pop the controller sliding right (sliding left), similar to AppStore app
enum Nav {
case a
}
struct MainView: View {
…

Peter Lapisu
- 19,915
- 16
- 123
- 179
6
votes
0 answers
SwiftUI: Repeat animation forever with delay at the end, without autoreverse
I want to repeat an animation forever, without it to autoreverse, and with a delay/pause between the repetitions after the animation played.
I know there is a .delay() modifier, but it delays the beginning of the animation:
let ani =…

ixany
- 5,433
- 9
- 41
- 65
6
votes
2 answers
SwiftUI Animation from @Published property changing from outside the View
SwiftUI offers .animation() on bindings that will animate changes in the view. But if an @Published property from an @ObserveredObject changes 'autonomously' (e.g., from a timer), while the view will update in response to the change, there is no…

c_booth
- 2,185
- 1
- 13
- 22
6
votes
2 answers
SwiftUI - how to override nested offset/position animations?
Consider this simple example:
struct TestView: View {
@State private var enabled = false
var body: some View {
Circle()
.foregroundColor(.red)
.overlay(
Circle()
…

roozbubu
- 1,106
- 4
- 14
- 30
6
votes
0 answers
SwiftUI Asymmetric Transition delay is not working
I am trying to create an animation for presenting and dismissing a group of objects. I have:
if self.showSignInButtons {
Group {
Button(action: {}) { ... }
HStack { ... }
Button(action: {}) { ... }
}.transition(
…
user9440625
5
votes
1 answer
Interrupting a SwiftUI animation with a drag gesture
Apple has made it easier than ever this year to smoothly animate a view after performing a drag gesture, by automatically using the final velocity of the drag gesture as the initial velocity of the animation. Here is a simple example:
struct…

Tim Vermeulen
- 12,352
- 9
- 44
- 63
5
votes
0 answers
SwiftUI: Use Match Geometry Effect When Navigating Between Views Using a Navigation Link
My home view contains a CustomView that opens a detailed view via a NavigationLink when tapped. The detailed view also contains the CustomView, just in a different location.
Can I use the Match Geometry Effect to transition/animate the location of…

yambo
- 1,388
- 1
- 15
- 34
5
votes
0 answers
SwiftUI Transitions have different implementation?
I have been testing how transitions work based on SwiftUI-labs but I found that transitions should not all be implemented in the same way.
Based on the previous article:
Note that since XCode 11.2, transitions no longer work with implicit
…

Aнгел
- 1,361
- 3
- 17
- 32
4
votes
1 answer
SwiftUI animation not working using animation(_:value:)
In SwiftUI, I've managed to make a Button animate right when the view is first drawn to the screen, using the animation(_:) modifier, that was deprecated in macOS 12.
I've tried to replace this with the new animation(_:value:) modifier, but this…

Dan
- 274
- 6
- 14