Coder Social home page Coder Social logo

citruz / gklparallaxpictures Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pyro2927/gklparallaxpictures

0.0 3.0 0.0 4.04 MB

Parallax ViewController made specifically for showcasing multiple images

License: MIT License

Ruby 4.99% Objective-C 95.01%

gklparallaxpictures's Introduction

GKLParallaxPictures

This component allows you to display an image gallery on top of a simple UIView or UIWebView. Scroll and you will see a nice parallax effect.

Install

The easiest way to install this component is via CocoaPods.

Add the following line to your podfile:

pod 'GKLParallaxPictures'

Then run the pod install command and import GKLParallaxPicturesViewController.h where you plan to use this.

You can also install it manually. Just drag GKLParallaxPicturesViewController.h and GKLParallaxPicturesViewController.m in your project and import the .h file where you want to use this component.

How To Use

GKLParallaxPicturesViewController *paralaxViewController = [[GKLParallaxPicturesViewController alloc] initWithImages:imagesArray andContentView:contentView];

Where contentView is the detailed view you want below your images.

You can always add more images after the view controller is instantiated by calling:

[paralaxViewController addImages:moreImagesArray];

Image arrays can contain both istances of UIImage and NSString. In the latter case those will be URLs of those images which will be loaded asynchronously.

Displaying a web view

This is the reason I forked for. It was not possible to display an UIWebView as the contentView.

UIWebView *testWebView = [[UIWebView alloc] init];
[testWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://nshipster.com/"]]];

UIImage *testImage = [UIImage imageNamed:@"shovel"];
NSArray *images = @[testImage, testImage, testImage];

GKLParallaxPicturesViewController *paralaxViewController = [[GKLParallaxPicturesViewController alloc] initWithImages:images
                                                                                                      andContentWebView:testWebView];

Result:

URL Image Loading

GKLParallaxPictures accepts both UIImages and NSStrings (of an image URL) for adding UIImageViews into the top gallery. By default it uses dispatch_queue to load images asynchronously, but you can subclass GKLParallaxPictures and overwrite this method to handle image loading however you choose.

Default image loading:

-(void)loadImageFromURLString:(NSString*)urlString forImageView:(UIImageView*)imageView{
	dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
	dispatch_async(queue, ^{
    	NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]];
    	dispatch_sync(dispatch_get_main_queue(), ^{
        	UIImage *downloadedImage = [[UIImage alloc] initWithData:imageData];
        	[imageView setImage:downloadedImage];
    	});
	});
}

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.