Git Product home page Git Product logo

confile / sccollectionviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from notbenoit/sccollectionviewcontroller

1.0 2.0 0.0 288 KB

This framework provides a controller to subclass, which presents a UICollectionView with builtin animations for a growing header (scale effect), a parallax effect, and a navigation bar background which fades in and out as you scroll through the UICollectionView.

License: MIT License

Ruby 3.23% Swift 89.73% C++ 7.04%

sccollectionviewcontroller's Introduction

SCCollectionViewController

SCCollectionViewController

This framework provides a controller to subclass, which presents a UICollectionView with builtin animations for a growing header (scale effect), a parallax effect, and a navigation bar background which fades in and out as you scroll through the UICollectionView.

Requirements

  • iOS 8.0+
  • Xcode 6.3 (Usage of Swift 1.2)

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:

$ gem install cocoapods

To add SCCollectionViewController to your project, add this lines to your Podfile:

use_frameworks!
pod 'SCCollectionViewController', '~> 1.0'

The flag use_frameworks! is used because this framework is entirely written in Swift, and generates a .framework file.

Manual

  • Simply add the SCCollectionViewController.xcodeproj to your workspace and add its framework output as a dependency of your project (see the Sample project).
  • You can also build the framework and directly link it to your target.

Usage

CollectionView layout setup

You can customize some properties to change the appearance of the controller.

  • cellMargin: CGFloat = 5 It's the spacing between two lines, and the edge insets for left and right (left and right margins).
  • cellHeight: CGFloat = 120 Corresponds to the height of every cell.
  • headerBaseHeight: CGFloat = 170 The height of the header when not scaled.

Growing header and parallax

First, you MUST subclass SCCollectionViewController, and provide your own implementation for the following methods :

func configureCell(cell: UICollectionViewCell, indexPath: NSIndexPath)
func configureHeader(header: UICollectionReusableView)
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int

You can also overrides any delegate method which is not declared final in the SCCollectionViewController.

Combine this subclass with your views and models, and you'll be able to customize the cells and headers as you like.

You'll have automatically the growing header, and parallax effects.

Fading navigation bar

For the fading effect, you'll have to push your SCCollectionViewController in a navigation controller. Your navigation controller should have a navigation bar of type SCNavigationBar because it overrides the alpha property of the UINavigationBar (to only have the background fading, and not the navigation items). If you do not use the SCNavigationBar, the whole bar will fade out and so will the navigation items.

You can set the class of the navigation bar directly in your nib or storyboard file, or when you instantiate your UINavigationController with init(navigationBarClass: AnyClass?, toolbarClass: AnyClass?)

Limitations

Right now, the SCCollectionViewController is made for a single section in the UICollectionView.

Changelog

1.0.0

Initial version

Creator

License

SCCollectionViewController is released under the MIT license. See LICENSE for details.

sccollectionviewcontroller's People

Contributors

notbenoit avatar

Stargazers

confile avatar

Watchers

confile avatar James Cloos 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.