Welcome to the documentation for GTScrollNavigationBar.
Installation
To install GTScrollNavigationBar, you can use CocoaPods by adding it to your Podfile:
pod 'GTScrollNavigationBar'
Usage
Once GTScrollNavigationBar is installed, you can start using it in your project. Here’s how:
- Import the GTScrollNavigationBar module into your class:
- Add a scrollable navigation bar to your view controller:
- Configure the navigation bar as needed (e.g., setting titles, items, or appearance):
- Set the delegate for the scroll navigation bar (optional):
- Add the scroll navigation bar to your view hierarchy:
import GTScrollNavigationBar
let scrollNavigationBar = GTScrollNavigationBar()
// Example configuration
scrollNavigationBar.titles = ["Home", "About", "Contact"]
scrollNavigationBar.barTintColor = UIColor.red
scrollNavigationBar.titleColor = UIColor.white
scrollNavigationBar.delegate = self
view.addSubview(scrollNavigationBar)
Customization
GTScrollNavigationBar can be customized to fit your project’s requirements. Here are some customization options:
- Appearance: Set barTintColor, translucent, and other appearance-related properties to customize the navigation bar’s appearance.
- Titles: Customize the titles of the navigation bar using the titles property.
- Items: Add UIBarButtonItem items to the navigation bar using the items property.
- Scrolling behavior: Adjust scrolling insets or enable/disable scroll expansion using the appropriate properties.
Examples
Here are a few examples to help you get started:
- Example 1: Simple scrollable navigation bar with default settings.
// Create and add GTScrollNavigationBar
let scrollNavigationBar = GTScrollNavigationBar()
view.addSubview(scrollNavigationBar)
// Create and add GTScrollNavigationBar
let scrollNavigationBar = GTScrollNavigationBar()
scrollNavigationBar.barTintColor = UIColor.blue
scrollNavigationBar.titleColor = UIColor.white
// Add items
let item1 = UIBarButtonItem(title: "Item 1", style: .plain, target: self, action: #selector(item1Tapped))
let item2 = UIBarButtonItem(title: "Item 2", style: .plain, target: self, action: #selector(item2Tapped))
scrollNavigationBar.items = [item1, item2]
view.addSubview(scrollNavigationBar)
API Reference
GTScrollNavigationBar provides the following API:
Congratulations! You have successfully set up GTScrollNavigationBar in your project. Use the provided examples and API reference to customize the navigation bar according to your requirements.
If you have any questions or need further assistance, please feel free to reach out to us.