I just upgrade to Xcode 11 Beta 5 and update my SwiftUI project.
In previous version I wanted to use PresentationLink component to show up a modal. I h
This is the same issue as https://stackoverflow.com/a/57087399/3179416
Just move your .sheet
outside of your ForEach
.
import SwiftUI
struct Testing : View {
var listViewItems: [Int] = [1, 2, 3]
@State var show = false
var body: some View {
VStack {
HStack {
VStack(alignment: .leading) {
Text("Project title").font(.largeTitle).fontWeight(.heavy)
Text("Project subtitle").foregroundColor(Color.gray)
}
Spacer()
}.padding(.top, 78).padding(.leading, 60)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 30) {
ForEach(listViewItems, id: \.self) { item in
GeometryReader { geometry in
Button(action: { self.show.toggle()}) {
Text("Button")
.rotation3DEffect(Angle(degrees: Double((geometry.frame(in: .global).minX - 30) / -30)), axis: (x: 0, y: 10, z: 0))
}
}.frame(width: 246, height: 360)
}
}.padding(30)
Spacer()
}.frame(width: UIScreen.main.bounds.width, height: 480)
.sheet(isPresented: self.$show, content: { Text("Modal") })
Spacer()
}
}
}