Contents

Aeastr/UIPortalBridge

<div align="center"> <h1><b>UIPortalBridge</b></h1> <p> A lightweight wrapper around Apple's private <code>_UIPortalView</code> for UIKit and SwiftUI. </p> </div>

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

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)
        }
    }
}

PortalView Options

PortalView(
    source: container,
    hidesSource: false,
    matchesAlpha: true,
    matchesTransform: true,
    matchesPosition: true
)

Using with Raw UIView

If you have a UIView reference:

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

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 | | 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

Package Metadata

Repository: Aeastr/UIPortalBridge

Stars: 21

Forks: 0

Open issues: 0

Default branch: main

Primary language: swift

License: MIT

README: README.md