Swiftpack.co -  globulus/swiftui-navigation-bar-styling as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
globulus/swiftui-navigation-bar-styling
Style a navigation bar in SwiftUI - changing its background color, text color, style its status bar.
.package(url: "https://github.com/globulus/swiftui-navigation-bar-styling.git", from: "1.0.0")

SwiftUINavigationBarStyling

Style a navigation bar in SwiftUI - changing its background color, text color, as well as styling the status bar. The end result looks like this:

in action

Recipe

Check out this recipe for in-depth description of the component and its code. Check out SwiftUIRecipes.com for more SwiftUI recipes!

Sample usage

Changing navigation bar background and text color:

var body: some View {
  NavigationView {
    VStack {
      Text("Hello World!")
    }.navigationBarColor(.blue, textColor: .white) // HERE
  }
}

Changing status bar style - in your SceneDelegate.swift, replace UIHostingController with StyledHostingController:

if let windowScene = scene as? UIWindowScene {
  let window = UIWindow(windowScene: windowScene)
  window.rootViewController = StyledHostingController(statusBarStyle: .lightContent, rootView: contentView) // HERE
  self.window = window
  window.makeKeyAndVisible()
}

Installation

This component is distrubuted as a Swift package.

GitHub

link
Stars: 2
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

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