Transition in SwiftUI 5 & iOS 17

DevTechie
DevTechie
Published in
6 min readAug 30, 2023

--

Transition in SwiftUI 5 & iOS 17

Transition is a visual effect that can be applied to a view or a view hierarchy when it appears, disappears, or changes. Transitions provide animations and visual cues that enhance the user interface and improve the overall user experience.

With the release of iOS 17 and SwiftUI 5, developers now have the ability to create custom transitions in SwiftUI, offering greater flexibility and control over the various stages of a transition. This functionality is achieved through the introduction of a new protocol called Transition.

Before we create our own custom transition using the new protocol, let’s create a view to try some of the existing SwiftUI provided transitions.

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

var body: some View {
VStack {
Spacer()
if showDetails {
Text("DevTechie.com")
.transition(.move(edge: .top))

Text("Learn iOS Development")
.transition(.slide)

Text("SwiftUI | UIKit | Machine Learning")
.transition(.scale)
}

Spacer()

Button("Know more about DevTechie.com") {
withAnimation {
showDetails.toggle()
}…

--

--