1

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 controllerenter image description here

2 Answers 2

1

Yes, it is possible to create something like this in SwiftUI, but you would not generally use VC's.

Sign up to request clarification or add additional context in comments.

1 Comment

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
1

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

I need it to present at that size on a button tap and also hide on a button tap, also with sliding down functionality

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.