I need to create a partial view controller, and want to do it in SwiftUI, but being fairly new to SwiftUI I'm not sure if it's possible. Is it possible to create something like this in SwiftUI? Where the purple is a viewcontroller and the background is another view controller
2 Answers
Yes, it is possible to create something like this in SwiftUI, but you would not generally use VC's.
1 Comment
aFella
I guess a view would suffice, not sure how I would go about making it slidable to dismiss though. Done this 100 times with UIKit but this SwiftUI is kicking my ass
In swiftUI this is just two views. Heres an example. You could use UIViewControllers for the top and bottom view by using. UIViewControllerRepresentable protocol
see docs here: https://developer.apple.com/documentation/swiftui/uiviewcontrollerrepresentable
struct SplitView: View {
struct TopView: View {
var body: some View {
ScrollView(.vertical) {
LazyVGrid(columns:[GridItem(.adaptive(minimum: 100, maximum: 150))] ) {
ForEach(0..<100) { item in
Text("item: \(item)")
}
}
}
}
}
struct BottomView: View {
var body: some View {
ScrollView(.horizontal) {
LazyHGrid(rows: [GridItem(.adaptive(minimum: 50, maximum: 100))] ) {
ForEach(0..<100) { item in
Text("item: \(item)")
}
}.background(Color.purple)
}
}
}
var body: some View {
GeometryReader { proxy in
VStack {
TopView()
.frame(height: proxy.size.height * 2/3)
BottomView()
.frame(height: proxy.size.height * 1/3)
}
}
}
}
1 Comment
aFella
I need it to present at that size on a button tap and also hide on a button tap, also with sliding down functionality