NOTE: Pod version requires 1.2.0 & later
Animate your Custom View using TableView, CollectionView OR ScrollView
.
NOTE: In below presentation, if animation looks laggy, wait till page completes it loading. It's smooth as you scrolls
Animation up to statusbar Animation up to zero
Animation up to custom value Animation up to zero without blurr
Things you can do, Please checkout example project to build similar.
Animation up to custom value
// Pass objects for appearance and disappearance of those according to scrolling.
viewKJNavigation.disappearanceObjects(instances: [labelCustomViewTitle, labelCustomViewSubtitle])
viewKJNavigation.appearanceObjects(instances: [viewNavigation])
- Swift 3.0.1+
- iOS 9.0+
KJNavigationViewAnimation is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'KJNavigationViewAnimation', '~> 0.1.0'
KJNavigationViewAnimation will be used via interface builder.
-
Add Custom View
(UIView)
at the top in your interface builder. AddKJNavigationViewAnimation
inClass
property at Identity Inspector of added view. -
You've to add
Height
constraint to your Custom View, don't add identifier to it, library will detect height automatically.
Use following properties to edit it's default functionality. Add your settings in viewDidLoad
.
// declare instance of KJNavigationViewAnimation by connecting it to UIView outlet in interface builder
@IBOutlet weak var viewKJNavigation: KJNavigationViewAnimation!
override func viewDidLoad() {
super.viewDidLoad()
// For TableView
viewKJNavigation.setupFor(Tableview: yourTableView,
viewController: self)
// Animate up to statusbar.
viewKJNavigation.topbarMinimumSpace = .statusBar
// If you want blurr background of navigation view.
viewKJNavigation.isBlurrBackground = true
// assign delegate of TableView, CollectionView OR ScrollView with self.
tableview.delegate = self
}
// For CollectionView
viewKJNavigation.setupFor(CollectionView: yourCollectionView,
viewController: self)
// For ScrollView
viewKJNavigation.setupFor(Scrollview: yourScrollView,
viewController: self)
// Animate up to zero.
viewKJNavigation.topbarMinimumSpace = .none
// Animate up to custom property.
viewKJNavigation.topbarMinimumSpace = .custom(height: 64)
You have to extend your viewController
class with UIScrollViewDelegate
, and connect TableView, CollectionView OR ScrollView delegate to self
. Last step to call KJNavigationViewAnimation scrollview methods
as below from UIScrollViewDelegate delegate methods
extension ViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
// viewKJNavigation is my declared KJNavigationViewAnimation property in ViewController class
viewKJNavigation.scrollviewMethod?.scrollViewDidScroll(scrollView)
}
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
viewKJNavigation.scrollviewMethod?.scrollViewWillBeginDragging(scrollView)
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
viewKJNavigation.scrollviewMethod?.scrollViewDidEndDragging(scrollView, willDecelerate: decelerate)
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
viewKJNavigation.scrollviewMethod?.scrollViewDidEndDecelerating(scrollView)
}
}
Skype: kiranjasvanee Kiran Jasvanee, kiran.jasvanee@yahoo.com
KJNavigationViewAnimation is available under the MIT license. See the LICENSE file for more info.