轻量级、易于使用且酷炫的 iOS 图像查看器。
它提供以下功能:
使用很简单。以下是最简单的实现示例
- (void)onSomeImageClicked:(id)sender {
NSMutableArray* imageUrls = [NSMutableArray new];
NSMutableArray* placeHoldeImages = [NSMutableArray new];
NSMutableArray* referenceRects = [NSMutableArray new];
NSUInteger imageIndex = 0;
UIView* referenceView = nil;
//configure your imageUrls, placeHoldeImages, referenceRects, imageIndex and referenceView
//...
CLImageViewer* imagesViewer = [CLImageViewer new];
CLImageInfo* imagesInfo = [CLImageInfo new];
imagesInfo.imageURLs = imageUrls;
imagesInfo.placeholderImages = placeHoldeImages;
imagesInfo.referenceView = referenceView;
imagesInfo.referenceRects = referenceRects;
imagesInfo.startImageIndex = imageIndex;
imagesViewer.imageInfo = imagesInfo;
imagesViewer.fromController = weakSelf;
[imagesViewer showImageViewFromOriginPosition];
}
更详细的信息可以在 CLImageViewerDemo 中找到。
就是这样。
有两种方法可以将 CLImageViewer 集成到项目中
pod 'CLImageViewer'
仅本地图片
如果您还没有网页图片,只需在设置 CLImageInfo
实例时设置 placeholderImages
属性,不要设置 imageURLs
属性即可。
自动滚动到原始位置
在某些情况下,您查看的图像的原始位置超出了屏幕。
在这种情况下,您可以设置 needSrollToOrigin
属性为 YES
,在设置 CLImageInfo
实例时。同时,应添加一个元素的 referenceRects
属性,其值为第一个打开的图像。
之后,当您单击任何查看的图像时,图像列表将自动滚动到您首先打开的图像,然后回到原始位置。
MIT 许可证,请参阅包含的文件。