Giter Club home page Giter Club logo

irphotogallery's Introduction

Build Status Platform

IRPhotoGallery

  • IRPhotoGallery is a powerful photo gallery for iOS.

Features

  • Support multiple gallery modes.
    • Horizontal
    • Vertical
    • Normal
    • Deletable
    • Scalable
    • HasButton
    • NoButton
  • Full screen gallery.
  • Customable functions.
  • Amazing camera.

Install

Git

  • Git clone this project.
  • Copy this project into your own project.
  • Add the .xcodeproj into you project and link it as embed framework.

Options

  • You can remove the demo and ScreenShots folder.

Cocoapods

  • Add pod 'IRPhotoGallery' in the Podfile
  • pod install

Usage

Basic

  • Use PhotoManageViewController, it include multi parts: Gallery, Preview, Camera, Album, Filters, etc...
NSBundle *bundle = [NSBundle bundleForClass:[PhotoManageViewController class]];
photoManageViewController = [[PhotoManageViewController alloc] initWithNibName:@"PhotoManageViewController" bundle:bundle];
photoManageViewController.delegate = self;
photoManageViewController.cameraDelegate = self;
[IRCameraColor setTintColor: [UIColor whiteColor]];

[self.navigationController pushViewController:photoManageViewController animated:YES];
  • Use PhotoManageBrowser, it just a gallery view
photoManageBrowser = [[PhotoManageBrowser alloc] init];
[photoManageBrowser setStyle:Normal];
[photoManageBrowser setDirection:ScrollDirectionHorizontal];
__weak ViewController* wSelf = self;
[photoManageBrowser setItemSelectedBlock:^(NSIndexPath *indexPath) {
    NSBundle *bundle = [NSBundle bundleForClass:[PhotoGalleryViewController class]];
    PhotoGalleryViewController* photoGalleryViewController = [[PhotoGalleryViewController alloc] initWithNibName:@"PhotoGalleryViewController" bundle:bundle];
    photoGalleryViewController.delegate = wSelf;
    photoGalleryViewController.imageIndex = indexPath.row;
    [wSelf presentViewController:photoGalleryViewController animated:YES completion:nil];
}];
photoManageBrowser.delegate = self;
[self.view addSubview:photoManageBrowser];
  • PhotoManageBrowserStyle
PhotoManageViewController
Normal
Deletable
Scalable
[photoManageBrowser setStyle:Normal];
  • PhotoManageBrowserStyle
PhotoManageBrowserScrollDirection
ScrollDirectionVertical
ScrollDirectionHorizontal
[photoManageBrowser setDirection:ScrollDirectionHorizontal];
  • Delegates
#pragma mark - PhotoManageBrowserDelegate
- (NSUInteger)numberOfPhotos {
    return photos.count;
}

- (NSString *)titleOfPhotoWithIndex:(NSInteger)index {
    return [photos objectAtIndex:index].note;
}

- (id)imageOrPathStringOfPhotoWithIndex:(NSInteger)index {
    
    return [images objectAtIndex:index];
}

#pragma mark - CameraViewControllerDelegate
- (void)didTakePhoto:(UIImage *)image Note:(NSString *)note {
    Photo *photo = [NSEntityDescription insertNewObjectForEntityForName:@"Photo" inManagedObjectContext:context];
    photo.photo = UIImagePNGRepresentation(image);
    photo.note = note;
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] saveContext];
    [self reloadPhotos];
    [photoManageViewController reloadUI];
}

- (void)doUpdatePhoto:(UIImage *)image Note:(NSString *)note Completed:(nullable IRCompletionBlock)completedBlock {
    [photoManageViewController showLoading:YES];
    NSInteger index = [images indexOfObject:image];
    Photo *photo = [photos objectAtIndex:index];
    photo.photo = UIImagePNGRepresentation(image);
    photo.note = note;
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] saveContext];
    if (completedBlock) {
        completedBlock(YES);
    }
    [photoManageViewController reloadUI];
    [photoManageViewController showLoading:NO];
}

- (void)doDeletePhoto:(UIImage *)image {
    NSInteger index = [images indexOfObject:image];
    Photo *photo = [photos objectAtIndex:index];
    [context deleteObject:photo];
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] saveContext];
    [self reloadPhotos];
    [photoManageViewController reloadUI];
}

Advanced settings

  • Customize functions of PhotoManageBrowser, 4 blocks let you override the default feature
@property (nonatomic, copy) CurrentPageChangedBlock currentPageChangedBlock;
@property (nonatomic, copy) ItemSelectedBlock itemSelectedBlock;
@property (nonatomic, copy) DeleteClickBlock deleteClickBlock;
@property (nonatomic, copy) EditClickBlock editClickBlock;
  • Use PhotoGalleryViewController, it is a simple gallery view controller
NSBundle *bundle = [NSBundle bundleForClass:[PhotoGalleryViewController class]];
PhotoGalleryViewController* photoGalleryViewController = [[PhotoGalleryViewController alloc] initWithNibName:@"PhotoGalleryViewController" bundle:bundle];
photoGalleryViewController.delegate = wSelf;
photoGalleryViewController.imageIndex = indexPath.row;
[wSelf presentViewController:photoGalleryViewController animated:YES completion:nil];

Screenshots

PhotoManageViewController PhotoManageBrowser
PhotoManageViewController PhotoManageBrowser
Camera Album
Camera Album
PhotoGalleryViewController Full Screen Gallery
PhotoGalleryViewController Full Screen Gallery

irphotogallery's People

Contributors

irons163 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.