Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

 
 

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

UIPortalBridge

A lightweight wrapper around Apple's private _UIPortalView for UIKit and SwiftUI.

iOS 17+ Swift 6.0 License: MIT

Portal views display a live mirror of another view. The mirrored content updates in real-time.

Looking for SwiftUI transitions? See Portal (experimental, pure SwiftUI) or Transmission (mature, UIKit-backed).

WARNING: Private API Usage

This package uses Apple's private _UIPortalView API. Apps using private APIs may be rejected by App Store Review. Use at your own discretion. UIPortalBridge, Aether, and any maintainers assume no responsibility for App Store rejections, app crashes, or any other issues arising from the use of this package. By importing UIPortalBridge, you accept full responsibility for any consequences.

Installation

dependencies: [
    .package(url: "https://github.com/Aeastr/UIPortalBridge", from: "1.0.0")
]
import UIPortalBridge

UIKit

let sourceView = UILabel()
sourceView.text = "Hello"

let portal = UIPortalView()
portal.sourceView = sourceView

// Optional configuration
portal.hidesSourceView = false  // Hide the source while portaling
portal.matchesAlpha = true      // Match source alpha
portal.matchesTransform = true  // Match source transform
portal.matchesPosition = true   // Match source position
portal.allowsHitTesting = false  // Allow hit testing on the portal
portal.forwardsClientHitTestingToSourceView = false // Forward hit tests to the source

Check portal.isAvailable to verify the private API is available on the current iOS version.

SwiftUI

Basic Usage

struct ContentView: View {
    @State private var container = SourceViewContainer {
        Text("Original Content")
            .padding()
            .background(.blue)
    }

    var body: some View {
        VStack {
            // Source view
            SourceViewRepresentable(
                container: container,
                content: Text("Original Content")
                    .padding()
                    .background(.blue)
            )

            // Portal (live mirror)
            PortalView(source: container)
        }
    }
}

PortalMirrorView Options

PortalMirrorView(
    source,
    hidesSource: false,
    matchesAlpha: true,
    matchesTransform: true,
    matchesPosition: true,
    allowsHitTesting: false,
    forwardsClientHitTestingToSourceView: false
)

Using with Raw UIView

If you have a UIView reference:

PortalViewRepresentable(
    sourceView: myUIView,
    hidesSourceView: false,
    matchesAlpha: true,
    matchesTransform: true,
    matchesPosition: true,
    allowsHitTesting: false,
    forwardsClientHitTestingToSourceView: false
)

API

UIPortalView

Property Type Default Description
sourceView UIView? nil The view to mirror
isAvailable Bool - Whether the private API is available (read-only)
hidesSourceView Bool false Hide source while portaling
allowsHitTesting Bool false Allow hit testing on the portal
forwardsClientHitTestingToSourceView Bool false Forward hit tests on mirrored content to the source view
matchesAlpha Bool true Match source alpha
matchesTransform Bool true Match source transform
matchesPosition Bool true Match source position

SourceViewContainer

Holds a SwiftUI view and exposes its underlying UIView for portaling.

Property Type Description
view UIView The underlying UIView
Method Description
update(content:) Update the container's content

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages