UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Transition insertion not working

Forums > SwiftUI

Hi, code is from a Paul example with transitions (tha asymmetric). Anyway transition on view appear never shows. How to fix it? Thanks

struct ContentView: View {
    @State private var showDetails = false

    var body: some View {
        VStack {
            Button("Press to show details") {
                withAnimation {
                    showDetails.toggle()
                }
            }

            if showDetails {
                Text("Details go here.")
                    .transition(.asymmetric(insertion: .move(edge: .leading), removal: .move(edge: .bottom)))
            }
        }

    }
}

3      

I have copied and pasted the code into XCode and ran it on an iPhone 11 and iphone 12 Pro Max simulators (portrait and landscape orientations).

It works fine in both. When the button is pressed, the text comes in from the left, and on the second button press, moves off downwards.

So it must be something else.

I am assuming that you are using Xcode 12.5, and running it on the simulators not the preview canvas, is that right?

3      

You are right, xCode 12.4... How do I fix it with 12.4?

3      

On real device it effectively works, Thanks!

3      

I tried it on XCode 12.4 (12.5 is the latest official release) and it works fine in the simulators.

It won't work properly in the Preview Canvas.

As you said it works OK on an actual device.

Glad i could help.

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.