RLImageBrowser
功能介绍
- 支持 png、jpeg、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;
返回需要做动画的视图,并告知浏览器哪个视图的哪个 image 用于动画。
要求
iOS 8
Xcode 10
安装
RLImageBrowser 可以直接通过 CocoaPods安装, 请在Podfile中添加:
pod 'RLImageBrowser'
作者
kinarobin, [email protected]
如果在使用过程中有任何好的需求或建议,或者遇到任何问题,欢迎随时提交issue或pr。
许可协议
RLImageBrowser 在MIT许可协议下提供。详细信息请参阅LICENSE文件。