MMParallaxCell 1.2

MMParallaxCell 1.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2015

Maintained by adad184.


Downloads

Total22,177
Week0
Month0

Installs

Apps351
Test Targets16
powered by Segment

GitHub

Stars463
Watchers19
Forks49
Issues1
Contributors3
Pull Requests1

Code

Files2
LOCLines of Code 125


  • By
  • Ralph Li

Total views Views in the last 24 hours

A subclass of UITableViewCell to present the parallax effect. MMParallaxCell is a drop-in solution, basically you don't need to configure anything, but also you can customize it youself.

Besides, you don't have to add additional codes in UITableView's Delegate Method, use it as natural as UITableViewCell :)

Parallax effect in demo project

demo

Installation

The preferred way of installation is via CocoaPods. Just add

pod 'MMParallaxCell'

and run pod install. It will install the most recent version of MMParallaxCell.

If you would like to use the latest code of MMParallaxCell use:

pod 'MMParallaxCell', :head

Usage

simply, you only need to set the image you wanna display.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString* cellIdentifier = @"CellIdentifier";
    MMParallaxCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil)
    {
        cell = [[MMParallaxCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

    [cell.parallaxImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://lorempixel.com/400/400/technics/%ld/",indexPath.row]]];

    return cell;
}

and you can change the ratio of the parallax effect.

@property (nonatomic, assign) CGFloat parallaxRatio; //ratio of cell height, should between [1.0f, 2.0f], default is 1.5f;

Changelog

v1.1 fixed crash caused by "removeObserver"

v1.0 you can custom or simply use it by

@interface MMParallaxCell : UITableViewCell

@property (nonatomic, strong) UIImageView *parallaxImage;

@property (nonatomic, assign) CGFloat parallaxRatio; //ratio of cell height, should between [1.0f, 2.0f], default is 1.5f;

@end