Git Product home page Git Product logo

dscollapseview's Introduction

DSCollapseView

Version

License

Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Min Supported Verion : iOS 8.0

Installation

DSCollapseView is available through CocoaPods. To install

it, simply add the following line to your Podfile:

pod "DSCollapseView"

Integration

No effort required for initializing.

Just add a view which you want to make collapsing, and assign it class DSCollapseView from Storyboard. This will set up a default collapse view which will collapse on dragging.

Now default collapse being setup, you definately want to customise some properties. Below are all the properties you can set

  • minHeight - Set the minimum height of the collapse view. i.e, the view can be dragged and collapsed minimum till this height only. Default value : 50

  • subViewConstraint - Probably the most important property if you want Magic to happen ! You need to pass the constraint of the subview whose movement you want on collapsing of the view. For example, in the gifs below, I have passed the top constraint of the topmost subview.

  • movementType - you can choose the movement type of the subviews when view is collapsing. There are 4 possible types of movement.

    1. AlongWith

      Translates the subviews along with collapsing view maintaining the margin constraint.

    2. Stationary

      Keeps the subviews clipped to their origin. They don't move on collapsing

    3. AlongWithFaster

      Translates the subviews relatively faster than collapseview. Give it a try!

    4. AlongWithSlower

      Translates the subviews slower than collapseview.

  • relativeMovement - The rate at which the SubViews will tranlsate. For example, if it's value is 2, the subviews will translate at 2x (twice the speed) of the collapsing of the collapse view. Default value : 1.5

  • appearingView - So, what happens in the end when view collapses to minimum height? Wolah !! You get a view to show. Set this value as the view you want to show when collapse view collapses. Suggestion - Keep the appearingView's height same as the minimum height of collape view.

Works great in landscape mode too :)

Code

Customizing is as simple as it gets !


// Sets the minimum height

collapseView.minHeight = 100



// Sets relative movement of SubViews

collapseView.relativeMovement = 2



// Type of SubView movement while view is collapsing

collapseView.movementType = .AlongWithSlower



// Passing the margin constraint

collapseView.subViewConstraint = self.topConstraint



// Setting the view to show when view is collapsed

collapseView.appearingView = sampleView



That's it! Enjoy :)

Do 'star' it if you like it! For suggestions drop me a mail! :)

Author

Divyansh Singh, [email protected]

License

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

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.