Giter Site home page Giter Site logo

sjrmanning / apparallaxheader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amnell/apparallaxheader

0.0 3.0 0.0 1.44 MB

Category that makes it super easy to add a parallax effect to your UIScrollView/UITableView

License: MIT License

Objective-C 95.25% Ruby 4.75%

apparallaxheader's Introduction

APParallaxHeader

This category makes it super easy to add a parallax header view to your scroll views. Other alternatives relies on subclassing of UIScrollView, UITableViewController or UITableView. Instead APParallaxHeader uses the Objective-C runtime to add the two following methods to UIScrollView without the need to do any subclassing.

- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height andShadow:(BOOL)shadow;
- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height;
- (void)addParallaxWithView:(UIView*)view andHeight:(CGFloat)height;

Demo

Demo

Installation

From CocoaPods

Add pod 'APParallaxHeader' to your Podfile (or pod 'APParallaxHeader', :head if you're feeling adventurous, and want to live on the edge).

Manually

Important note if your project doesn't use ARC: you must add the -fobjc-arc compiler flag to UIScrollView+ APParallaxHeader.m in Target Settings > Build Phases > Compile Sources.

  • Drag the APParallaxHeader/APParallaxHeader folder into your project.
  • #import UIScrollView+APParallaxHeader.h wherever you feel the need.

Usage

(see sample Xcode project in /Demo)

Adding Parallax image

[tableView addParallaxWithImage:[UIImage imageNamed:@"ImageName"] andHeight:160];

Adding Parallax custom view

Note: When adding a custom view. Either use APParallaxViewDelegate, auto layout constraints or contentMode to resize your custom view during scrolling.

UIView *customView = [[UIView alloc] init];
[customView setFrame:CGRectMake(0, 0, 320, 160)];
[self.tableView addParallaxWithView:customView andHeight:160];

[self.tableView.parallaxView setDelegate:self];

APParallaxViewDelegate

APParallaxViewDelegate will notify the delegate about resizing of the parallax view.

####Methods:####

  • - (void)parallaxView:(APParallaxView *)view willChangeFrame:(CGRect)frame
  • - (void)parallaxView:(APParallaxView *)view didChangeFrame:(CGRect)frame

ToDo

  • Ability to customize the drop shadow size, opacity, color etc.
  • Setting a minimum height
  • Setting contentMode of the imageView

Known issues

  • Section headers for tableviews with style UITableViewStylePlain will not be pinned as expected during scrolling.

Changelog

0.1.6

  • Re-added/fixed optional shadow implementation

0.1.5

  • Added delegate callbacks for APParallaxView resizes (APParallaxViewDelegate).

0.1.4

  • Ability to inititate with or without an inner shadow.
  • Ability to set a custom view as a parallax view.

0.1.3

  • Added an inner shadow

0.1.2

  • Initial release

Credits

APParallaxHeader is brought to you by Mathias Amnell at Apping AB. The code is inspired by Sam Vermette's work with SVPullToRefresh (especially the usage of objc/runtime.h to make it so easy to implement, without the need of subclassing).

License

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

apparallaxheader's People

Contributors

amnell avatar hoya avatar sjrmanning avatar

Watchers

 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.