Skip to content

Instantly share code, notes, and snippets.

@kirsteins
Created February 4, 2021 09:37

Revisions

  1. kirsteins created this gist Feb 4, 2021.
    21 changes: 21 additions & 0 deletions Transition.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    struct ContentView: View {
    @State var flag = false

    var body: some View {
    VStack(spacing: 0) {
    Circle().fill(Color.orange)
    if flag {
    Circle()
    .fill(Color.red)
    .transition(.opacity)
    .animation(.default)
    }
    }
    .background(Color.black.ignoresSafeArea())
    .onTapGesture {
    withAnimation {
    flag.toggle()
    }
    }
    }
    }