Sunday, March 10, 2024
HomeiOS Developmentios - Permit person interplay for internet hosting controller

ios – Permit person interplay for internet hosting controller


I take advantage of a internet hosting controller to current particular views above .sheets and .fullscreencovers. Once I current these small views utilizing the internet hosting controller then all of the background views get disabled. How can I make it in order that each the background views and internet hosting controller view each detect person interplay. In my case the video offered by the internet hosting controller solely takes up a nook of the display screen (the video is floating and could be dragged to any nook of the display screen), the video may also be clicked after which expands to the total display screen. If this isn’t potential with a internet hosting controller is there a special solution to current a view about all the things, together with .sheets and .fullscreencover?

I attempted doing hostingController?.view.isUserInteractionEnabled = false however then this permits interplay with the background and disables the internet hosting controller.

p1 p2 p3

struct SomeView: View {
    var physique: some View {
        ScrollView {
            //some content material
        }
    }
}
struct ContentView: View {
     var physique: some View {
          SomeView()
             .overlay {
                  TopVideoView()
             }
     }
}
struct TopView: View {
    var physique: some View {
        RoundedRectangle(cornerRadius: 10)
           .foregroundStyle(.blue).body(width: 100, top: 100)
    }
}
struct TopVideoView: View {
    @State non-public var hostingController: UIHostingController<TopView>? = nil

    func showImage() {
        let swiftUIView = TopView()
        hostingController = UIHostingController(rootView: swiftUIView)
        hostingController?.view.backgroundColor = .clear
        hostingController?.view.body = CGRect(
            x: 0,
            y: 0,
            width: UIScreen.essential.bounds.width,
            top: UIScreen.essential.bounds.top)

        if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
           let window = windowScene.home windows.first {
            window.addSubview(hostingController!.view)

            hostingController?.view.heart.x = window.heart.x
        }
    }

    func dismissImage() {
        hostingController?.view.removeFromSuperview()
        hostingController = nil
    }

    var physique: some View {
        VStack {}
            .onAppear { showImage() }
            .onDisappear { dismissImage() }
    }
}



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments