标签:
https://github.com/mwaterfall/MWPhotoBrowser
mwphotobrowser可以通过提供uiimage对象显示一个或多个图像,或URL的Web图像文件,或图书馆资产。照片处理下载和缓存浏览器从Web照片无缝。照片可以放大和平移,和可选的标题可以显示(可定制)。
浏览器也可以用于允许用户选择一个或更多的照片可以使用网格或主视图。
- (void)viewDidLoad
{
[super viewDidLoad];
// Browser
NSMutableArray *photos = [[NSMutableArray alloc] init];
NSMutableArray *thumbs = [[NSMutableArray alloc] init];
MWPhoto *photo;
BOOL displayActionButton = NO;
BOOL displaySelectionButtons = NO;
BOOL displayNavArrows = NO;
BOOL enableGrid = YES;
BOOL startOnGrid = NO;
// Photos
photo = [MWPhoto photoWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"photo5" ofType:@"jpg"]]];
photo.caption = @"Fireworks";
[photos addObject:photo];
photo = [MWPhoto photoWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"photo2" ofType:@"jpg"]]];
photo.caption = @"The London Eye is a giant Ferris wheel situated on the banks of the River Thames, in London, England.";
[photos addObject:photo];
photo = [MWPhoto photoWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"photo3" ofType:@"jpg"]]];
photo.caption = @"York Floods";
[photos addObject:photo];
photo = [MWPhoto photoWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"photo4" ofType:@"jpg"]]];
photo.caption = @"Campervan";
[photos addObject:photo];
// Options
self.photos = photos;
self.thumbs = thumbs;
//
// Create browser
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = displayActionButton;//分享按钮,默认是
browser.displayNavArrows = displayNavArrows;//左右分页切换,默认否
browser.displaySelectionButtons = displaySelectionButtons;//是否显示选择按钮在图片上,默认否
browser.alwaysShowControls = displaySelectionButtons;//控制条件控件 是否显示,默认否
browser.zoomPhotosToFill = NO;//是否全屏,默认是
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
browser.wantsFullScreenLayout = YES;//是否全屏
#endif
browser.enableGrid = enableGrid;//是否允许用网格查看所有图片,默认是
browser.startOnGrid = startOnGrid;//是否第一张,默认否
browser.enableSwipeToDismiss = YES;
[browser showNextPhotoAnimated:YES];
[browser showPreviousPhotoAnimated:YES];
[browser setCurrentPhotoIndex:1];
browser.photoTitles = @[@"000",@"111",@"222",@"333"];//标题
// [self presentViewController:browser animated:YES completion:nil];
[self.navigationController pushViewController:browser animated:NO];
}
#pragma mark - MWPhotoBrowserDelegate
- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
return _photos.count;
}
- (id )photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
if (index < _photos.count)
return [_photos objectAtIndex:index];
return nil;
}
个人建议仔细看一下MWPhotoBrowser的各种属性,会帮助你更快的掌握MWPhotoBrowser的使用,,,
标签:
原文地址:http://www.cnblogs.com/anyezhuixing/p/4707179.html