GithubHelp home page GithubHelp logo

xiachufang / rlimagebrowser Goto Github PK

View Code? Open in Web Editor NEW
2.0 7.0 1.0 18.96 MB

A simple image browser support gesture to dismiss.

License: MIT License

Ruby 0.86% Objective-C 99.14%
browser image photo image-browser photo-browser photos images

rlimagebrowser's Introduction

RLImageBrowser

Version

功能介绍

  • 支持png、jgeg、webp、gif图片格式
  • 支持小视频播放
  • 支持图片手势返回
  • 预加载图片

示例展示

使用方法

创建RLPhoto:

NSArray *photosURL = @[
[NSURL URLWithString:@"http://www.ioncannon.net/wp-content/uploads/2011/06/test9.webp"], 
[NSURL URLWithString:@"http://littlesvr.ca/apng/images/SteamEngine.webp"], 
[NSURL URLWithString:@"https://apng.onevcat.com/assets/elephant.png"]
];

NSMutableArray *photos = [NSMutableArray new];
for (NSURL *url in photosURL) {
  RLPhoto *photo = [RLPhoto photoWithURL:url];
  [photos addObject:photo];
}
NSArray *photos = [RLPhoto photosWithURLs:photosURL]; 

展示RLImageBrowser:

RLImageBrowser *browser = [[RLImageBrowser alloc] initWithPhotos:photos];
//设置代理 <RLImageBrowserDelegate>
browser.delegate = self;
//展示资源数量
browser.displayCounterLabel = YES;
//轻点关闭图片浏览器
browser.dismissOnTouch = YES;
//设置进度条颜色,默认白色
browser.progressTintColor = [UIColor orangeColor];
//设置动画时间 默认0.25s
browser.animationDuration = 0.3;
//获取当前的Index
NSUInteger index = browser.currentPageIndex;
// present 图片浏览器
[viewController presentViewController:browser animated:YES completion:nil];

RLImageBrowserDelegate

- (void)willAppearPhotoBrowser:(RLImageBrowser *)photoBrowser;
- (void)willDisappearPhotoBrowser:(RLImageBrowser *)photoBrowser;
- (void)imageBrowser:(RLImageBrowser *)photoBrowser didShowPhotoAtIndex:(NSUInteger)index;
- (void)imageBrowser:(RLImageBrowser *)photoBrowser didDismissAtPageIndex:(NSUInteger)index;
- (void)imageBrowser:(RLImageBrowser *)photoBrowser willDismissAtPageIndex:(NSUInteger)index;
- (RLCaptionView *)imageBrowser:(RLImageBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index;
- (void)photoBrowser:(RLImageBrowser *)imageBrowser imageFailed:(NSUInteger)index imageView:(RLDetectingImageView *)imageView;

如果展示需要过渡动画,必须实现协议:

- (UIView <RLTransitionProtocol> *)imageBrowser:(RLImageBrowser *)photoBrowser transitionViewForPhotoAtIndex:(NSUInteger)index;

返回需要做动画的视图,并且告知browser这个视图哪个image是用来做动画的.

要求

iOS 8
Xcode 10

安装

RLImageBrowser 可以直接通过 CocoaPods安装, 直接在Podfile添加:

pod 'RLImageBrowser'

Author

kinarobin, [email protected]
如果在使用中有好的需求及建议,或者遇到什么bug,欢迎随时issue、pr

License

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

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.