Skip to content

fabioknoedt/YCSlideShowImageView

Repository files navigation

YCSlideShowImageView

Pod Version Pod Platform Pod License Dependency Status

A very simple subclass of UIImageView with the option to animate like a Slide Show between 2+ images.

alt tag

Usage

MyExample.m

@interface MyExample ()

@property (nonatomic, weak) IBOutlet YCSlideShowImageView *imageView;

@end

@implementation MyExample

- (void)aMethod {

	/// Run in a loop of image URLs OR in a loop of stored images.
    for (NSString *imageURL in _imageURLs) {

    	/// Here we start the download using AFNetworking (just an example). You can use any downloader.
		NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:imageURL]];
		AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
		requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
		[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
		    
			/// Here we add each downloaded image to the Slide Show.
		    [_imageView addImage:image];

		} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
		    NSLog(@"Image error: %@", error);
		}];
		[requestOperation start];
	}
}

@end

If you want to reset the animation, just call:

[_imageView emptyImageArray];

There are 3 public properties that you can use to customize the animation duration (animationDurationTime), the delay between the transitions (animationDelay) and also the options of the animation (animationOptions).

CGFloat animationDurationTime;
CGFloat animationDelay;
UIViewAnimationOptions animationOptions;

Support

Runs fine in iOS6+ and supports ARC.

Contributors

Made in Berlin

* [Fabio Knoedt](https://github.com/fabioknoedt) * Rubén Xifré

About

A very simple subclass of UIImageView with the option to animate like a Slide Show between 2+ images.

Resources

License

Stars

Watchers

Forks

Packages

No packages published