RLImageBrowser 1.2.4

RLImageBrowser 1.2.4

Maintained by kinarobin, ZZTest, SunYongji.



 
Depends on:
SDWebImage>= 5.0.2
SDWebImageWebPCoder>= 0.2.1
 

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.