美文网首页
MWPhotoBrowser使用

MWPhotoBrowser使用

作者: 不规则先生 | 来源:发表于2016-12-22 11:06 被阅读156次

MWPhotoBrowser

// Create array of MWPhoto objects

self.photos = [NSMutableArray array];

// Add photos

[photos addObject:[MWPhoto photoWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]]]];

[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg"]]];

[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b.jpg"]]];

// Add video with poster photo

MWPhoto *video = [MWPhoto photoWithURL:[NSURL URLWithString:@"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/e15/11192696_824079697688618_1761661_n.jpg"]];

video.videoURL = [[NSURL alloc] initWithString:@"https://scontent.cdninstagram.com/hphotos-xpa1/t50.2886-16/11200303_1440130956287424_1714699187_n.mp4"];

[photos addObject:video];

// Create browser (must be done each time photo browser is

// displayed. Photo browser objects cannot be re-used)

MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];

// Set options

browser.displayActionButton = YES; // Show action button to allow sharing, copying, etc (defaults to YES)

browser.displayNavArrows = NO; // Whether to display left and right nav arrows on toolbar (defaults to NO)

browser.displaySelectionButtons = NO; // Whether selection buttons are shown on each image (defaults to NO)

browser.zoomPhotosToFill = YES; // Images that almost fill the screen will be initially zoomed to fill (defaults to YES)

browser.alwaysShowControls = NO; // Allows to control whether the bars and controls are always visible or whether they fade away to show the photo full (defaults to NO)

browser.enableGrid = YES; // Whether to allow the viewing of all the photo thumbnails on a grid (defaults to YES)

browser.startOnGrid = NO; // Whether to start on the grid of thumbnails instead of the first photo (defaults to NO)

browser.autoPlayOnAppear = NO; // Auto-play first video

// Customise selection images to change colours if required

browser.customImageSelectedIconName = @"ImageSelected.png";

browser.customImageSelectedSmallIconName = @"ImageSelectedSmall.png";

// Optionally set the current visible photo before displaying

[browser setCurrentPhotoIndex:1];

// Present

[self.navigationController pushViewController:browser animated:YES];

// Manipulate

[browser showNextPhotoAnimated:YES];

[browser showPreviousPhotoAnimated:YES];

[browser setCurrentPhotoIndex:10];

相关文章

网友评论

      本文标题:MWPhotoBrowser使用

      本文链接:https://www.haomeiwen.com/subject/woicvttx.html