- 4 different interactive dismissal animations(Rotation, Scale, Slide).
- 3 different background styles(Blur Photo, Blur, Black).
- 2 different loading styles(Determinate, Indeterminate).
- 2 different pager styles(Dot, Text).
- Support bounce animation.
- Optimized for image which has a very large height.
- Can display one or more images by providing either image urls or UIImage objects.
- Custom image downloader library support.
NSArray *urls = @[@"http://ww4.sinaimg.cn/bmiddle/a15bd3a5jw1f12r9ku6wjj20u00mhn22.jpg",
@"http://ww2.sinaimg.cn/bmiddle/a15bd3a5jw1f01hkxyjhej20u00jzacj.jpg"];
NSMutableArray *items = @[].mutableCopy;
for (int i = 0; i < urls.count; i++) {
// Get the large image url
NSString *url = [urls[i] stringByReplacingOccurrencesOfString:@"bmiddle" withString:@"large"];
UIImageView *imageView = _imageViews[i];
KSPhotoItem *item = [KSPhotoItem itemWithSourceView:imageView imageUrl:[NSURL URLWithString:url]];
[items addObject:item];
}
KSPhotoBrowser *browser = [KSPhotoBrowser browserWithPhotoItems:items selectedIndex:0];
[browser showFromViewController:self];
NSArray *names = @[@"a.jpg", @"b.jpg"];
NSMutableArray *items = @[].mutableCopy;
for (int i = 0; i < names.count; i++) {
UIImageView *imageView = _imageViews[i];
KSPhotoItem *item = [KSPhotoItem itemWithSourceView:imageView image:[UIImage imageNamed:names[i]]];
[items addObject:item];
}
KSPhotoBrowser *browser = [KSPhotoBrowser browserWithPhotoItems:items selectedIndex:0];
[browser showFromViewController:self];
- Update cocoapods to the latest version.
- Add
pod 'KSPhotoBrowser'
to your Podfile. - Run
pod install
orpod update
. - Import
KSPhotoBrowser.h
.
- Download all the files of KSPhotoBrowser and add source files to your project.
- Manually install YYWebImage to your project.
- Import
KSPhotoBrowser.h
.
It use YYWebImage
as default image downloader, you can also use your custom image downloader like SDWebImage
, Kingfisher
and so on.
To use a custom image downloader, you need to create a class and make it conforms to KSImageManager
protocol and implement those methods inside that protocol.
For convenience, I have already created KSSDImageManager
to support SDWebImage 4.0
as an example in the demo, you can also use it directly.
Finally, just use the code below to set your class to KSPhotoBrowser
before you use the browser to show images.
[KSPhotoBrowser setImageManagerClass:KSSDImageManager.class]
This library requires iOS 8.0+
and Xcode 8.0+
.
KSPhotoBrowser is provided under the MIT license. See LICENSE file for details.