Skip to content

A subclass of UITableViewCell to present the parallax effect

License

Notifications You must be signed in to change notification settings

carabina/MMParallaxCell

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MMParallaxCell A subclass of UITableViewCell to present the parallax effect

MMPlaceHolder

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

About

A subclass of UITableViewCell to present the parallax effect

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 92.9%
  • C 3.5%
  • Ruby 2.2%
  • Shell 1.4%