GithubHelp home page GithubHelp logo

netguru / carlenscollectionviewlayout Goto Github PK

View Code? Open in Web Editor NEW
544.0 21.0 39.0 57 KB

An easy-to-use Collection View Layout for card-like animation.

Home Page: https://www.netguru.com/codestories/introducing-carlenscollectionviewlayout-a-new-open-source-ios-tool-by-netguru

License: MIT License

Objective-C 4.39% Swift 89.87% Ruby 5.75%
collectionview collectionviewlayout uicollectionview uicollectionviewlayout uicollectionviewflowlayout collectionviewflowlayout swift ios swift4 flowlayout

carlenscollectionviewlayout's Introduction

CarLensCollectionViewLayout

An easy-to-use Collection View Layout for card-like animation ๐ŸŽ‰

CarLensCollectionViewLayout was created out of the implementation in CarLens application ๐Ÿš˜. The image above exactly shows the screen from the app!

Requirements

CarLensCollectionViewLayout is written in Swift 4.2 and supports iOS 9.0+.

Usage

Basic Usage

The two main steps are needed for the configuration of CarLensCollectionViewLayout:

Step 1

Assign CarLensCollectionViewLayout to yours collection view layout:

collectionView.collectionViewLayout = CarLensCollectionViewLayout()

or initialize your collection view with CarLensCollectionViewLayout:

UICollectionView(frame: .zero, collectionViewLayout: CarLensCollectionViewLayout())

Step 2

Subsclass CarLensCollectionViewCell and call configure(topView: UIView, cardView: UIView) during the cellโ€™s initialization:

class CollectionViewCell: CarLensCollectionViewCell {
    override init(frame: CGRect) {
	super.init(frame: frame)
	configure(topView: upperView, cardView: bottomView)
    }
}

The sample implementation is available in Demo project.

Customization

Layout

You can also initialize CarLensCollectionViewLayout with a CarLensCollectionViewLayoutOptions object by passing any of the parameters available. Others will be configured automatically.

Parameters:

minimumSpacing - A minimum spacing between cells.

decelerationRate - A deceleration for a scroll view.

shouldShowScrollIndicator - A value indicating whether collection view should have a scroll indicator.

itemSize - The size to use for cells.

Example:

let options = CarLensCollectionViewLayoutOptions(minimumSpacing: 40)
collectionView.collectionViewLayout = CarLensCollectionViewLayout(options: options)

Cell

While subsclassing CarLensCollectionViewCell you can call configure(...) with an additional parameter topViewHeight. The card view height will be calculated based on this value.

Example:

class CollectionViewCell: CarLensCollectionViewCell {
    override init(frame: CGRect) {
	super.init(frame: frame)
	configure(topView: upperView, cardView: bottomView, topViewHeight: 300)
    }
}

Installation

CocoaPods

If you're using CocoaPods, add the following dependency to your Podfile:

use_frameworks!
pod 'CarLensCollectionViewLayout', '~> 1.2.0'

Carthage

If you're using Carthage, add the following dependency to your Cartfile:

github "netguru/CarLensCollectionViewLayout" ~> 1.2.0

About

This project is made with โค๏ธ by Netguru and maintained by Anna-Mariia Shkarlinska.

License

CarLensCollectionViewLayout is licensed under the MIT License. See LICENSE.md for more info.

Read More

Related Links

carlenscollectionviewlayout's People

Contributors

anyashka avatar pgryka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.