All Projects → zrkb → FFBackgroundParallax

zrkb / FFBackgroundParallax

Licence: other
Background Parallax is a simple example for parallax scrolling based on several UIScrollViews.

Programming Languages

objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to FFBackgroundParallax

react-rellax
React Parallax component using Rellax.js
Stars: ✭ 39 (-53.01%)
Mutual labels:  parallax-scrolling
AFTPhotoScroller
A simple photo browser using like iOS photo app.
Stars: ✭ 20 (-75.9%)
Mutual labels:  parallax-scrolling
URParallaxScrollAnimator
Show an animation as far as moved scroll while scrolling at the scroll view
Stars: ✭ 34 (-59.04%)
Mutual labels:  parallax-scrolling
Parallaxie
Easiest, Responsive and Customizable Parallax jQuery Plugin
Stars: ✭ 65 (-21.69%)
Mutual labels:  parallax-scrolling
smooth-parallax
Smooth Parallax makes it a lot easier to move objects when the page scroll with ease.
Stars: ✭ 66 (-20.48%)
Mutual labels:  parallax-scrolling
hongkong
A parallax scroll effect plugin
Stars: ✭ 46 (-44.58%)
Mutual labels:  parallax-scrolling
universal-parallax
Easy parallax plugin using pure javascript. Also works on mobile platforms. Cross browser support.
Stars: ✭ 107 (+28.92%)
Mutual labels:  parallax-scrolling
Rallax.js
Dead simple parallax scrolling.
Stars: ✭ 1,441 (+1636.14%)
Mutual labels:  parallax-scrolling
Brady
A camera library with parallax scrolling and aspect ratios for LÖVE.
Stars: ✭ 50 (-39.76%)
Mutual labels:  parallax-scrolling
Perspective
🖼Parallax scrolling effect. And more.
Stars: ✭ 80 (-3.61%)
Mutual labels:  parallax-scrolling

FFBackgroundParallax

License CocoaPods Platform Language CocoaPods Tag

Background Parallax Scrolling is a simple example for parallax scrolling based on several UIScrollViews. This library is simply a UIView subclass with two UIScrollView, one for content and the second for the background image.

Preview

Installation

Instead of adding the source files directly to your project, you may want to consider using CocoaPods to manage your dependencies. Follow the instructions on the CocoaPods site to install the gem, and specify FFBackgroundParallax as a dependency in your Podfile with:

pod 'FFBackgroundParallax', '~> 1.1.0'

But if you want to do it the old fashioned way, just add FFBackgroundParallax.h/m files to your project.

Requirements

  • ARC
  • iOS 8.0 and above

Usage

First you need to import the header file

#import "FFBackgroundParallax.h"

Then define your Total Items and your Item Image Size

#define kImageSize 250.0
#define kTotalItems 6

Add subviews normally to the public property contentScrollView

@implementation ViewController

- (void)viewDidLoad {
	[super viewDidLoad];
	
	[self configureBackgroundParallax];
}

- (void)configureBackgroundParallax {
	
	FFBackgroundParallax *backgroundParallax = [[FFBackgroundParallax alloc] initWithFrame:self.view.bounds];
	[backgroundParallax setImageBackground:[UIImage imageNamed:@"mountains.jpg"]];
	
	for (NSUInteger i = 0; i < kTotalItems; i++) {
		CGFloat xOrigin = (i * CGRectGetWidth(backgroundParallax.frame)) + (CGRectGetWidth(backgroundParallax.bounds) / 2) - (kImageSize / 2);
		
		UIImageView *badge = [[UIImageView alloc] initWithFrame:CGRectMake(xOrigin, (CGRectGetHeight(backgroundParallax.frame) / 2) - (kImageSize / 2), kImageSize, kImageSize)];
		
		badge.image = [UIImage imageNamed:[NSString stringWithFormat:@"%i", (i + 1)]];
		
		[backgroundParallax.contentScrollView addSubview:badge];
	}
	
	[backgroundParallax.contentScrollView setContentSize:CGSizeMake(CGRectGetWidth(backgroundParallax.frame) * kTotalItems, CGRectGetHeight(backgroundParallax.frame))];
	
	[self.view addSubview:backgroundParallax];
}

@end

To add your background image, simply call:

- (void)setImageBackground:(UIImage *)image

if you need vertical compatibility you need to change scrollingMode property to FFParallaxModeVertical when initialize the class:

FFBackgroundParallax *backgroundParallax = [[FFBackgroundParallax alloc] initWithFrame:self.view.bounds];
backgroundParallax.scrollingMode = FFParallaxModeVertical;

Todo

  • Vertical Compatibility
  • Swift Demo

Credits

Collaboration

Feel free to collaborate with ideas, issues and/or pull requests.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].