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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.