Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haifengkao/swiftui-navigation-bar-color
Change SwiftUI Navigation Bar Color for different View
https://github.com/haifengkao/swiftui-navigation-bar-color
navigation navigationbar swift swiftui
Last synced: 3 months ago
JSON representation
Change SwiftUI Navigation Bar Color for different View
- Host: GitHub
- URL: https://github.com/haifengkao/swiftui-navigation-bar-color
- Owner: haifengkao
- License: mit
- Created: 2021-07-22T11:08:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-18T12:07:01.000Z (over 3 years ago)
- Last Synced: 2024-04-22T14:01:54.083Z (9 months ago)
- Topics: navigation, navigationbar, swift, swiftui
- Language: Swift
- Homepage:
- Size: 1.4 MB
- Stars: 25
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftUINavigationBarColor
[![Version](https://img.shields.io/cocoapods/v/NavigationBarColor.svg?style=flat)](https://cocoapods.org/pods/NavigationBarColor)
[![License](https://img.shields.io/cocoapods/l/NavigationBarColor.svg?style=flat)](https://cocoapods.org/pods/NavigationBarColor)
[![Platform](https://img.shields.io/cocoapods/p/NavigationBarColor.svg?style=flat)](https://cocoapods.org/pods/NavigationBarColor)Change SwiftUI NavigationBar background color per screen.
![NavigationColorBar](https://github.com/haifengkao/SwiftUI-Navigation-Bar-Color/raw/main/screens/screen1.gif)
## UsageFor `NavigationBarColor` to work, you have to set the NavigationBar's background to be transparent.
If you want to change the navigation bar's text color, you have to set it here as well.
```
import SwiftUINavigationBarColor
...NavigationView {
VStack {
Text("Hello, world!").padding()
}
}.navigationTransparentBar(tintColor: .white) // mandatory
```After that, we can set the NavigationBar's background for each screen.
```
VStack {
Text("Hello, Red!").padding()
}.navigationBarBackground {
Color.red.shadow(radius: 1) // don't forget the shadow under the opaque navigation bar
}
```## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
`ios 14`## Installation
NavigationBarColor is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'NavigationBarColor'
```## Author
Hai Feng Kao, [email protected]
## License
NavigationBarColor is available under the MIT license. See the LICENSE file for more info.