一个简单的iOS照片浏览器:MWPhotoBrowser
jopen
10年前
这是一个简单的iOS照片浏览器可选的网格视图,标题和选中功能。
MWPhotoBrowser能够展示一张或多张图片,图片可以来自 UIImage
objects, 或 URLs to files, Web图片或资源库。这个照片浏览器能够无缝地处理下载和缓存来自Web的图片。照片可放大,缩小,平移,和可选的(可定制),可以显示标题。
// Create array of MWPhoto objects self.photos = [NSMutableArray array]; [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"]]]; // 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.wantsFullScreenLayout = YES; // iOS 5 & 6 only: Decide if you want the photo browser full screen, i.e. whether the status bar is affected (defaults to YES) // 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];