All Projects → AvdLee → Swiftuikitview

AvdLee / Swiftuikitview

Licence: mit
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftuikitview

Bfkit Swift
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster.
Stars: ✭ 963 (+141.96%)
Mutual labels:  xcode, uikit
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+2589.95%)
Mutual labels:  xcode, uikit
Tap water
【声明:未发布前,勿使用,勿star,预计2020年11月底发布】Flutter tab_bar组件,支持中间带加号按钮的TabBar,支持Lottie动画。iTeaTime(技术清谈)团队出品。Highly customizable tabBar and tabBarController for Flutter
Stars: ✭ 52 (-86.93%)
Mutual labels:  xcode, uikit
Shadowview
An iOS Library that makes shadows management easy on UIView.
Stars: ✭ 391 (-1.76%)
Mutual labels:  uikit, uiview
Stepslider
StepSlider its custom implementation of slider such as UISlider for preset integer values.
Stars: ✭ 391 (-1.76%)
Mutual labels:  xcode, uikit
Cyltabbarcontroller
[EN]It is an iOS UI module library for adding animation to iOS tabbar items and icons with Lottie, and adding a bigger center UITabBar Item. [CN]【中国特色 TabBar】一行代码实现 Lottie 动画TabBar,支持中间带+号的TabBar样式,自带红点角标,支持动态刷新。【iOS13 & Dark Mode & iPhone XS MAX supported】
Stars: ✭ 6,605 (+1559.55%)
Mutual labels:  xcode, uikit
Ios Learning Materials
📚Curated list of articles, web-resources, tutorials and code repositories that may help you dig a little bit deeper into iOS [and Apple Platforms].
Stars: ✭ 1,380 (+246.73%)
Mutual labels:  xcode, uikit
Swiftai
SwiftAI, write Swift code smart. SwiftAI can generate Model class from JSON now. Codable and HandyJSON is supported. More features will be add.
Stars: ✭ 470 (+18.09%)
Mutual labels:  xcode, uikit
LSAdditions
The Category of Commonly used controls and you can create a control quickly(Object, Control ...)
Stars: ✭ 15 (-96.23%)
Mutual labels:  uikit, uiview
Mhsoftui
Extension for Neumorphic Soft UI effect in Swift
Stars: ✭ 151 (-62.06%)
Mutual labels:  xcode, uikit
Swiftui
A collaborative list of awesome SwiftUI resources. Feel free to contribute!
Stars: ✭ 774 (+94.47%)
Mutual labels:  xcode, uikit
UIView-SmoothCorners
An App-Store-safe way to enable smooth continuous corners on UIView that works on iOS 11, 12 and 13.
Stars: ✭ 91 (-77.14%)
Mutual labels:  uikit, uiview
Rangeseekslider
RangeSeedSlider provides a customizable range slider like a UISlider.
Stars: ✭ 524 (+31.66%)
Mutual labels:  xcode, uikit
Bfkit
BFKit is a collection of useful classes and categories to develop Apps faster.
Stars: ✭ 811 (+103.77%)
Mutual labels:  xcode, uikit
Ttsegmentedcontrol
An elegant, animated and customizable segmented control for iOS created by Tapptitude
Stars: ✭ 471 (+18.34%)
Mutual labels:  xcode, uikit
Dtgradientbutton
Easy way to set gradient background to your buttons.
Stars: ✭ 76 (-80.9%)
Mutual labels:  xcode, uikit
Squishbutton
A button that squishes when pressed. As seen in the Clips app.
Stars: ✭ 401 (+0.75%)
Mutual labels:  xcode, uikit
Sourceful
A syntax highlighting source editor for iOS and macOS using UITextView and NSTextView.
Stars: ✭ 449 (+12.81%)
Mutual labels:  xcode, uikit
Dckit
Set of iOS controls with useful IBInspectable properties. Written on Swift.
Stars: ✭ 144 (-63.82%)
Mutual labels:  xcode, uikit
TinderUISamples
[ING] - TinderのようなUIを様々な実装で実現してみる
Stars: ✭ 30 (-92.46%)
Mutual labels:  uikit, uiview

SwiftUIKitView

Swift Version Dependency frameworks Twitter

Easily use UIKit views in SwiftUI.

  • Convert UIView to SwiftUI View
  • Create Xcode Previews from UIView elements
  • SwiftUI functional updating UIView properties using a protocol with Associated Types.

You can read more about Getting started with UIKit in SwiftUI and visa versa.

Examples

Using a UIKit view directly in SwiftUI:

import SwiftUI
import SwiftUIKitView

struct SwiftUIwithUIKitView: View {
    var body: some View {
        NavigationView {
            UILabel() // <- This can be any `UIKit` view.
                .swiftUIView(layout: .intrinsic) // <- This is returning a SwiftUI `View`.
                .set(\.text, to: "Hello, UIKit!") // <- Use key paths for updates.
                .set(\.backgroundColor, to: UIColor(named: "swiftlee_orange"))
                .fixedSize()
                .navigationTitle("Use UIKit in SwiftUI")
        }
    }
}

Creating a preview provider for a UIView:

import SwiftUI
import SwiftUIKitView

struct UILabelExample_Preview: PreviewProvider {
    static var previews: some View {
        UILabel() // <- This is a `UIKit` view.
            .swiftUIView(layout: .intrinsic) // <- This is a SwiftUI `View`.
            .set(\.text, to: "Hello, UIKit!") // <- Use key paths for updates.
            .fixedSize() // <- Make sure the size is set
            .previewLayout(.sizeThatFits)
            .previewDisplayName("UILabel Preview Example")
    }
}

Which results in the following preview:

KeyPath updating

This framework also comes with a KeyPathReferenceWritable protocol that allows to update objects using functions and writable KeyPath references:

/// Defines a type that is configurable using reference writeable keypaths.
public protocol KeyPathReferenceWritable {
    associatedtype T
    associatedtype U
    
    func set<Value>(_ keyPath: ReferenceWritableKeyPath<T, Value>, to value: Value) -> U
}

public extension KeyPathReferenceWritable {
    func set<Value>(_ keyPath: ReferenceWritableKeyPath<Self, Value>, to value: Value) -> Self {
        self[keyPath: keyPath] = value
        return self
    }
}

/// Add inheritance for NSObject types to make the methods accessible for many default types.
extension NSObject: KeyPathReferenceWritable { }

This can be used as follows:

UILabel()
    .set(\.text, to: "Example")

And allows to easily build up SwiftUI style view configurations to keep the same readability when working in SwiftUI.

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but this SDK does support its use on supported platforms.

Once you have your Swift package set up, adding the SDK as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/AvdLee/SwiftUIKitView.git", .upToNextMajor(from: "1.0.0"))
]

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

License

SwiftUIKitView is available under the MIT license, and uses source code from open source projects. See the LICENSE file for more info.

Author

This project is originally created by Antoine van der Lee. I'm open for contributions of any kind to make this project even better.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].