一個簡單的iOS照片瀏覽器:MWPhotoBrowser
這是一個簡單的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:@"// 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];</pre>
![]()
![]()
![]()
![]()
![]()