Swiftpack.co - dankinsoid/UIKitViews as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by dankinsoid.
dankinsoid/UIKitViews 1.1.0
Wrapper for a UIKit views that you use to integrate that view into your SwiftUI view hierarchy.
⭐️ 0
🕓 2 weeks ago
iOS
.package(url: "https://github.com/dankinsoid/UIKitViews.git", from: "1.1.0")

UIKitViews

Description

Easily use UIViews and UIViewControllers in SwiftUI. UIKitViews is based on key paths chaining

Examples

import SwiftUI
import UIKitViews

struct SomeView: View {

    @State private var text = "Some text that"

    // Access to UIKitView environments
    @Environment(\UIView.tintColor) private var tintColor: UIColor?

    var body: some View {
        NavigationView {
            UILabel()§
                .text(text) // <- Use key paths chaining for updates.
                .font(.systemFont(ofSize: 23))
                .do { label in 
                    // some custom action on redraw
                }
        
            UIKitView { () -> UILabel in // <- Use `UKitView` directly where the `§` operator is not enough.
            	  let otherLabel = UILabel()
                otherLabel.setContentCompressionResistancePriority(.required, for: .vertical)
                return otherLabel   
            } update: { view, context in
                view.text = text
            }
        }
        .uiKitViewEnvironment(\UILabel.textColor, .green) // <- Set any UIKit view properties as an environment
    }
}

Installation

  1. Swift Package Manager

Create a Package.swift file.

// swift-tools-version:5.5
import PackageDescription

let package = Package(
  name: "SomeProject",
  dependencies: [
    .package(url: "https://github.com/dankinsoid/UIKitViews.git", from: "1.1.0")
  ],
  targets: [
    .target(name: "SomeProject", dependencies: ["UIKitViews"])
  ]
)
$ swift build

Author

dankinsoid, voidilov@gmail.com

License

UIKitViews is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics