Git Product home page Git Product logo

kjnavigationviewanimation's Introduction

KJNavigationViewAnimation

Twitter: @KiranJasvanee License: MIT Issues Forks Stars Language

NOTE: Pod version requires 1.2.0 & later

Preview

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

KJNavigationViewAnimation                     KJNavigationViewAnimation

                  Animation up to custom value                                                Animation up to zero without blurr

KJNavigationViewAnimation                     KJNavigationViewAnimation

Example

Things you can do, Please checkout example project to build similar.

               Animation up to custom value

KJNavigationViewAnimation

// Pass objects for appearance and disappearance of those according to scrolling.
viewKJNavigation.disappearanceObjects(instances: [labelCustomViewTitle, labelCustomViewSubtitle])    
viewKJNavigation.appearanceObjects(instances: [viewNavigation])

Requirements

  • Swift 3.0.1+
  • iOS 9.0+

Installation

KJNavigationViewAnimation is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'KJNavigationViewAnimation', '~> 0.1.0'

Usage

KJNavigationViewAnimation will be used via interface builder.

  • Add Custom View (UIView) at the top in your interface builder. Add KJNavigationViewAnimation in Class 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.


Properties

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)

Methods

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)
  }
}

Author

Skype: kiranjasvanee Kiran Jasvanee, [email protected]

License

KJNavigationViewAnimation is available under the MIT license. See the LICENSE file for more info.

kjnavigationviewanimation's People

Contributors

kiranjasvanee avatar rico237 avatar trickpirata avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.