Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
Created July 3, 2020 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseidhof/0f1667dc4acaeedde1059cc5b6b79293 to your computer and use it in GitHub Desktop.
Save chriseidhof/0f1667dc4acaeedde1059cc5b6b79293 to your computer and use it in GitHub Desktop.
SwiftUI bugs
//
// ContentView.swift
// Bug1
//
// Created by Chris Eidhof on 03.07.20.
//
import SwiftUI
struct ContentView: View {
@Namespace var ns
@State var selected: Bool = false
var body: some View {
let rect = Rectangle()
.fill(Color.red)
.frame(width: selected ? 200 : 100, height: selected ? 150 : 75)
.onTapGesture {
withAnimation(.easeInOut(duration: 3)) {
selected.toggle()
}
}
return VStack {
if !selected {
rect
.matchedGeometryEffect(id: "x", in: ns, isSource: false)
}
Spacer()
ScrollView {
HStack {
if selected {
rect
.matchedGeometryEffect(id: "x", in: ns, isSource: false)
}
}
}
.background(Color.gray)
.frame(height: 220)
}.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment