SwiftUIKit is a collection of useful extensions and utilities for SwiftUI. This library enhances SwiftUI development by providing a variety of view modifiers, UIKit wrappers, and additional functionalities. It includes components for handling UI appearance, user interactions, and more.
To use SwiftUIKit
in your project, copy the source files directly into your project, or use Swift Package Manager.
After installation, import the library into your SwiftUI views:
import SwiftUI
import SwiftUI_Kit
You can then use the provided extensions, components, and modifiers to enhance your views. Each extension and utility included in this library extends existing SwiftUI types or provides new functionality to make your code more concise and expressive. Refer to the extensions and components listed below for details on usage.
-
cornerRadius(_:corners:)
Applies rounded corners to specific corners of a view. -
embedInNavigationView()
Embeds the view in aNavigationView
. -
embedInScrollView(alignment:)
Embeds the view in aScrollView
. -
eraseToAnyView()
Converts the view toAnyView
. -
loaderSheet(isPresented:title:font:indicatorColor:titleColor:backgroundColor:)
Displays a loading sheet with a customizable activity indicator. -
navigationBarColor(_:shadowColor:titleColor:)
Modifies the navigation bar’s color, shadow, and title color. -
addVisualEffectAsBackground(effect:)
Adds aUIVisualEffect
as the background of the view. -
pullToRefresh(isRefreshing:)
Adds a pull-to-refresh capability to the view. -
allowSwipeToDismiss(_:)
Allows swipe-to-dismiss behavior on the view. -
uiKitOnAppear(_:)
Executes a closure when the view appears using UIKit’sviewDidAppear
.
-
ActivityIndicator
A SwiftUI wrapper forUIActivityIndicatorView
. -
MailView
A SwiftUI wrapper forMFMailComposeViewController
. -
PageControl
A SwiftUI wrapper forUIPageControl
. -
PagerView
A view that displays a paginated, swipeable collection of pages. -
PencilKitView
A SwiftUI wrapper forPKCanvasView
, allowing users to draw using PencilKit. -
SafariView
A SwiftUI wrapper forSFSafariViewController
. -
ShareSheet
A SwiftUI wrapper forUIActivityViewController
. -
VideoPlayerView
A SwiftUI wrapper forAVPlayerViewController
.
-
AnimatedRedactedModifier
Applies an animated redacted (shimmer) effect to a view. -
LoaderSheet
Displays a loading sheet with a customizable activity indicator. -
NavigationControllerConfigurator
Configures the navigation controller for the current view. -
RoundedCorner
A shape that rounds specific corners of a rectangle.
-
IfLetView
A view that conditionally displays content based on the presence of an optional value. -
IfLetViewPlaceholder
A view that conditionally displays content with a placeholder for thenil
case. -
UIKitAppear
Provides a way to execute a closure when the view appears using UIKit’sviewDidAppear
.
-
EdgeInsets
Provides utility methods to createEdgeInsets
. -
UIApplication
Retrieves the active window and ends editing. -
UIFont
Calculates the height of a text using the font. -
UIColor
ConvertsColor
toUIColor
. -
UIDevice
Utility properties for checking device types (e.g., iPhone SE, iPhone 8). -
PreviewDevice
Utility properties for common iOS devices.
This library is released under the MIT license. See LICENSE for details.