To run the example project, clone the repo, and run pod install
from the Example directory first.
- Swift >= 3.0
ALSlidingNavigationBar is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ALSlidingNavigationBar"
import ALSlidingNavigationBar
Create an object of type ALSlidingNavigationBar
using the default constructor and passing references of your navigation bar, navigation item and the view you would like to slide.
self.slidingNavigationBar = ALSlidingNavigationBar(
navigationBar: self.navigationController!.navigationBar,
navigationItem: self.navigationItem,
navigationBarView: self.navigationBarView
)
Important
The rect of the passed navigationBarView must have its origin at zero and its dimensions must be the same as navigationBar's frame's.
CGRect(
x: 0,
y: 0,
width: self.navigationController!.navigationBar.frame.width,
height: self.navigationController!.navigationBar.frame.height
)
There are two anchor types to choose from - view or offset.
self.slidingNavigationBar.setAnchor(view: self.anchorView)
self.slidingNavigationBar.setAnchor(offsetY: 150)
Call the didScroll
method on every scroll update, (e.g. didScroll
method from UIScrollViewDelegate
)
self.slidingNavigationBar.didScroll(offset: self.scrollView.contentOffset.y, convertView: self.view) {
Aleksander Lorenc, thaxsillion@gmail.com
ALSlidingNavigationBar is available under the MIT license. See the LICENSE file for more info.