[go: up one dir, main page]

Skip to content

Easily set the colors of the status bar in SwiftUI! 🌈

License

Notifications You must be signed in to change notification settings

fire-at-will/StatusBarColorKit

Repository files navigation

StatusBarColorKit

Twitter: @Fire_At_Will_

StatusBarColorKit lets you easily set the background color and style of the status bar in SwiftUI! 🌈

StatusBarKit

Usage

In your SceneDelegate.swift file, replace the existing UIHostingController with StatusBarColorManager and wrap your ContentView in an AnyView:

import StatusBarColorKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Create the SwiftUI view that provides the window contents.
        let contentView = ContentView()

        // Use a StatusBarColorManager as window root view controller.
        if let windowScene = scene as? UIWindowScene {
            let window = UIWindow(windowScene: windowScene)
            window.rootViewController = StatusBarColorManager(rootView: AnyView(contentView))
            self.window = window
            window.makeKeyAndVisible()
        }
    }
    // ...
}

Then, set the status bar's style and background color:

StatusBarColorManager.statusBarBackgroundColor = .systemBlue
StatusBarColorManager.statusBarStyle = .darkContent

And that's it!

Installation

StatusBarColorKit is a Swift package. Add this to your Package.swift file to use it:

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/fire-at-will/StatusBarColorKit", from: "0.1.0")
    ],
    ...
)

Contributions

PRs are always welcome! :)

About

Easily set the colors of the status bar in SwiftUI! 🌈

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages