├── .github └── ISSUE_TEMPLATE │ ├── feature-template.md │ └── issue-template.md ├── .gitignore ├── Images ├── banner.png └── preview.gif ├── LICENSE ├── Podfile ├── Podfile.lock ├── Pods ├── Manifest.lock ├── Pods.xcodeproj │ └── project.pbxproj ├── SDWebImage │ ├── LICENSE │ ├── README.md │ ├── SDWebImage │ │ ├── Core │ │ │ ├── NSButton+WebCache.h │ │ │ ├── NSButton+WebCache.m │ │ │ ├── NSData+ImageContentType.h │ │ │ ├── NSData+ImageContentType.m │ │ │ ├── NSImage+Compatibility.h │ │ │ ├── NSImage+Compatibility.m │ │ │ ├── SDAnimatedImage.h │ │ │ ├── SDAnimatedImage.m │ │ │ ├── SDAnimatedImageRep.h │ │ │ ├── SDAnimatedImageRep.m │ │ │ ├── SDAnimatedImageView+WebCache.h │ │ │ ├── SDAnimatedImageView+WebCache.m │ │ │ ├── SDAnimatedImageView.h │ │ │ ├── SDAnimatedImageView.m │ │ │ ├── SDDiskCache.h │ │ │ ├── SDDiskCache.m │ │ │ ├── SDImageAPNGCoder.h │ │ │ ├── SDImageAPNGCoder.m │ │ │ ├── SDImageCache.h │ │ │ ├── SDImageCache.m │ │ │ ├── SDImageCacheConfig.h │ │ │ ├── SDImageCacheConfig.m │ │ │ ├── SDImageCacheDefine.h │ │ │ ├── SDImageCacheDefine.m │ │ │ ├── SDImageCachesManager.h │ │ │ ├── SDImageCachesManager.m │ │ │ ├── SDImageCoder.h │ │ │ ├── SDImageCoder.m │ │ │ ├── SDImageCoderHelper.h │ │ │ ├── SDImageCoderHelper.m │ │ │ ├── SDImageCodersManager.h │ │ │ ├── SDImageCodersManager.m │ │ │ ├── SDImageFrame.h │ │ │ ├── SDImageFrame.m │ │ │ ├── SDImageGIFCoder.h │ │ │ ├── SDImageGIFCoder.m │ │ │ ├── SDImageGraphics.h │ │ │ ├── SDImageGraphics.m │ │ │ ├── SDImageIOCoder.h │ │ │ ├── SDImageIOCoder.m │ │ │ ├── SDImageLoader.h │ │ │ ├── SDImageLoader.m │ │ │ ├── SDImageLoadersManager.h │ │ │ ├── SDImageLoadersManager.m │ │ │ ├── SDImageTransformer.h │ │ │ ├── SDImageTransformer.m │ │ │ ├── SDMemoryCache.h │ │ │ ├── SDMemoryCache.m │ │ │ ├── SDWebImageCacheKeyFilter.h │ │ │ ├── SDWebImageCacheKeyFilter.m │ │ │ ├── SDWebImageCacheSerializer.h │ │ │ ├── SDWebImageCacheSerializer.m │ │ │ ├── SDWebImageCompat.h │ │ │ ├── SDWebImageCompat.m │ │ │ ├── SDWebImageDefine.h │ │ │ ├── SDWebImageDefine.m │ │ │ ├── SDWebImageDownloader.h │ │ │ ├── SDWebImageDownloader.m │ │ │ ├── SDWebImageDownloaderConfig.h │ │ │ ├── SDWebImageDownloaderConfig.m │ │ │ ├── SDWebImageDownloaderOperation.h │ │ │ ├── SDWebImageDownloaderOperation.m │ │ │ ├── SDWebImageDownloaderRequestModifier.h │ │ │ ├── SDWebImageDownloaderRequestModifier.m │ │ │ ├── SDWebImageError.h │ │ │ ├── SDWebImageError.m │ │ │ ├── SDWebImageIndicator.h │ │ │ ├── SDWebImageIndicator.m │ │ │ ├── SDWebImageManager.h │ │ │ ├── SDWebImageManager.m │ │ │ ├── SDWebImageOperation.h │ │ │ ├── SDWebImageOptionsProcessor.h │ │ │ ├── SDWebImageOptionsProcessor.m │ │ │ ├── SDWebImagePrefetcher.h │ │ │ ├── SDWebImagePrefetcher.m │ │ │ ├── SDWebImageTransition.h │ │ │ ├── SDWebImageTransition.m │ │ │ ├── UIButton+WebCache.h │ │ │ ├── UIButton+WebCache.m │ │ │ ├── UIImage+ForceDecode.h │ │ │ ├── UIImage+ForceDecode.m │ │ │ ├── UIImage+GIF.h │ │ │ ├── UIImage+GIF.m │ │ │ ├── UIImage+MemoryCacheCost.h │ │ │ ├── UIImage+MemoryCacheCost.m │ │ │ ├── UIImage+Metadata.h │ │ │ ├── UIImage+Metadata.m │ │ │ ├── UIImage+MultiFormat.h │ │ │ ├── UIImage+MultiFormat.m │ │ │ ├── UIImage+Transform.h │ │ │ ├── UIImage+Transform.m │ │ │ ├── UIImageView+HighlightedWebCache.h │ │ │ ├── UIImageView+HighlightedWebCache.m │ │ │ ├── UIImageView+WebCache.h │ │ │ ├── UIImageView+WebCache.m │ │ │ ├── UIView+WebCache.h │ │ │ ├── UIView+WebCache.m │ │ │ ├── UIView+WebCacheOperation.h │ │ │ └── UIView+WebCacheOperation.m │ │ └── Private │ │ │ ├── NSBezierPath+RoundedCorners.h │ │ │ ├── NSBezierPath+RoundedCorners.m │ │ │ ├── SDAsyncBlockOperation.h │ │ │ ├── SDAsyncBlockOperation.m │ │ │ ├── SDImageAPNGCoderInternal.h │ │ │ ├── SDImageAssetManager.h │ │ │ ├── SDImageAssetManager.m │ │ │ ├── SDImageCachesManagerOperation.h │ │ │ ├── SDImageCachesManagerOperation.m │ │ │ ├── SDImageGIFCoderInternal.h │ │ │ ├── SDInternalMacros.h │ │ │ ├── SDInternalMacros.m │ │ │ ├── SDWeakProxy.h │ │ │ ├── SDWeakProxy.m │ │ │ ├── SDmetamacros.h │ │ │ ├── UIColor+HexString.h │ │ │ └── UIColor+HexString.m │ └── WebImage │ │ └── SDWebImage.h ├── Target Support Files │ ├── Pods-YBImageBrowserDemo │ │ ├── Pods-YBImageBrowserDemo-Info.plist │ │ ├── Pods-YBImageBrowserDemo-acknowledgements.markdown │ │ ├── Pods-YBImageBrowserDemo-acknowledgements.plist │ │ ├── Pods-YBImageBrowserDemo-dummy.m │ │ ├── Pods-YBImageBrowserDemo-frameworks-Debug-input-files.xcfilelist │ │ ├── Pods-YBImageBrowserDemo-frameworks-Debug-output-files.xcfilelist │ │ ├── Pods-YBImageBrowserDemo-frameworks-Release-input-files.xcfilelist │ │ ├── Pods-YBImageBrowserDemo-frameworks-Release-output-files.xcfilelist │ │ ├── Pods-YBImageBrowserDemo-frameworks.sh │ │ ├── Pods-YBImageBrowserDemo-umbrella.h │ │ ├── Pods-YBImageBrowserDemo.debug.xcconfig │ │ ├── Pods-YBImageBrowserDemo.modulemap │ │ └── Pods-YBImageBrowserDemo.release.xcconfig │ ├── SDWebImage │ │ ├── SDWebImage-Info.plist │ │ ├── SDWebImage-dummy.m │ │ ├── SDWebImage-prefix.pch │ │ ├── SDWebImage-umbrella.h │ │ ├── SDWebImage.modulemap │ │ └── SDWebImage.xcconfig │ └── YYImage │ │ ├── YYImage-Info.plist │ │ ├── YYImage-dummy.m │ │ ├── YYImage-prefix.pch │ │ ├── YYImage-umbrella.h │ │ ├── YYImage.modulemap │ │ └── YYImage.xcconfig └── YYImage │ ├── LICENSE │ ├── README.md │ └── YYImage │ ├── YYAnimatedImageView.h │ ├── YYAnimatedImageView.m │ ├── YYFrameImage.h │ ├── YYFrameImage.m │ ├── YYImage.h │ ├── YYImage.m │ ├── YYImageCoder.h │ ├── YYImageCoder.m │ ├── YYSpriteSheetImage.h │ └── YYSpriteSheetImage.m ├── README.md ├── Video ├── YBIBVideoActionBar.h ├── YBIBVideoActionBar.m ├── YBIBVideoCell+Internal.h ├── YBIBVideoCell.h ├── YBIBVideoCell.m ├── YBIBVideoData+Internal.h ├── YBIBVideoData.h ├── YBIBVideoData.m ├── YBIBVideoTopBar.h ├── YBIBVideoTopBar.m ├── YBIBVideoView.h ├── YBIBVideoView.m └── YBImageBrowserVideo.bundle │ ├── ybib_bigPlay@2x.png │ ├── ybib_bigPlay@3x.png │ ├── ybib_cancel@2x.png │ ├── ybib_cancel@3x.png │ ├── ybib_circlePoint@2x.png │ ├── ybib_circlePoint@3x.png │ ├── ybib_pause@2x.png │ ├── ybib_pause@3x.png │ ├── ybib_play@2x.png │ └── ybib_play@3x.png ├── YBImageBrowser.podspec ├── YBImageBrowser ├── AuxiliaryView │ ├── YBIBAuxiliaryViewHandler.h │ ├── YBIBAuxiliaryViewHandler.m │ ├── YBIBLoadingView.h │ ├── YBIBLoadingView.m │ ├── YBIBToastView.h │ └── YBIBToastView.m ├── Base │ ├── NSObject+YBImageBrowser.h │ ├── NSObject+YBImageBrowser.m │ ├── YBIBAnimatedTransition.h │ ├── YBIBAnimatedTransition.m │ ├── YBIBCollectionView.h │ ├── YBIBCollectionView.m │ ├── YBIBCollectionViewLayout.h │ ├── YBIBCollectionViewLayout.m │ ├── YBIBContainerView.h │ ├── YBIBContainerView.m │ ├── YBIBDataMediator.h │ ├── YBIBDataMediator.m │ ├── YBIBScreenRotationHandler.h │ ├── YBIBScreenRotationHandler.m │ └── YBImageBrowser+Internal.h ├── Helper │ ├── YBIBCopywriter.h │ ├── YBIBCopywriter.m │ ├── YBIBIconManager.h │ ├── YBIBIconManager.m │ ├── YBIBPhotoAlbumManager.h │ ├── YBIBPhotoAlbumManager.m │ ├── YBIBSentinel.h │ ├── YBIBSentinel.m │ ├── YBIBUtilities.h │ └── YBIBUtilities.m ├── Image │ ├── YBIBImageCache+Internal.h │ ├── YBIBImageCache.h │ ├── YBIBImageCache.m │ ├── YBIBImageCell+Internal.h │ ├── YBIBImageCell.h │ ├── YBIBImageCell.m │ ├── YBIBImageData+Internal.h │ ├── YBIBImageData.h │ ├── YBIBImageData.m │ ├── YBIBImageLayout.h │ ├── YBIBImageLayout.m │ ├── YBIBImageScrollView.h │ ├── YBIBImageScrollView.m │ ├── YBIBInteractionProfile.h │ ├── YBIBInteractionProfile.m │ ├── YBImage.h │ └── YBImage.m ├── Protocol │ ├── YBIBCellProtocol.h │ ├── YBIBDataProtocol.h │ ├── YBIBGetBaseInfoProtocol.h │ ├── YBIBOperateBrowserProtocol.h │ ├── YBIBOrientationReceiveProtocol.h │ ├── YBImageBrowserDataSource.h │ └── YBImageBrowserDelegate.h ├── ToolView │ ├── YBIBSheetView.h │ ├── YBIBSheetView.m │ ├── YBIBToolViewHandler.h │ ├── YBIBToolViewHandler.m │ ├── YBIBTopView.h │ └── YBIBTopView.m ├── WebImageMediator │ ├── YBIBDefaultWebImageMediator.h │ ├── YBIBDefaultWebImageMediator.m │ └── YBIBWebImageMediator.h ├── YBImageBrowser.bundle │ ├── ybib_loading@2x.png │ ├── ybib_loading@3x.png │ ├── ybib_more@2x.png │ ├── ybib_more@3x.png │ ├── ybib_save@2x.png │ └── ybib_save@3x.png ├── YBImageBrowser.h └── YBImageBrowser.m ├── YBImageBrowserDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── YBImageBrowserDemo.xcscheme ├── YBImageBrowserDemo.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ ├── IDEWorkspaceChecks.plist │ └── WorkspaceSettings.xcsettings └── YBImageBrowserDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Example ├── Base │ ├── BaseListCell.h │ ├── BaseListCell.m │ ├── BaseListCell.xib │ ├── BaseListController.h │ └── BaseListController.m ├── File │ ├── BaseFileManager.h │ ├── BaseFileManager.m │ ├── ImageURLs.plist │ ├── localBigImage0.jpeg │ ├── localImage0.jpg │ ├── localImage1.gif │ ├── localLongImage0.jpeg │ └── localVideo0.mp4 ├── 图片显示预处理(例添加水印) │ ├── TestDController.h │ └── TestDController.m ├── 展示图片+视频 │ ├── TestAController.h │ └── TestAController.m ├── 添加到控制器使用(以相册为例) │ ├── TestEController.h │ ├── TestEController.m │ ├── TestImageBrowser.h │ └── TestImageBrowser.m ├── 用代理配置数据源(以相册为例) │ ├── TestFController.h │ └── TestFController.m ├── 自定义 Cell │ ├── TestCController.h │ ├── TestCController.m │ ├── TestCustomCell.h │ ├── TestCustomCell.m │ ├── TestCustomCell.xib │ ├── TestCustomData.h │ └── TestCustomData.m └── 自定义工具视图(例查看原图) │ ├── TestBController.h │ ├── TestBController.m │ ├── TestToolViewHandler.h │ └── TestToolViewHandler.m ├── Info.plist ├── MainController.h ├── MainController.m ├── MainListController.h ├── MainListController.m ├── MainNavigationController.h ├── MainNavigationController.m ├── PrefixHeader.pch └── main.m /.github/ISSUE_TEMPLATE/feature-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature template 3 | about: Suggest an idea for this project. 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | ### Feature Description 13 | 14 | 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/issue-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Issue template 3 | about: Asking questions or pointing out mistakes. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | ### Description 13 | 14 | 15 | 16 | ### Environment 17 | 18 | * YBImageBrowser version: 19 | * iOS version: 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | 19 | #CocoaPods 20 | #Pods -------------------------------------------------------------------------------- /Images/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Images/banner.png -------------------------------------------------------------------------------- /Images/preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Images/preview.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 杨波 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform:ios, '8.0' 2 | target ‘YBImageBrowserDemo’ do 3 | use_frameworks! 4 | 5 | 6 | pod 'SDWebImage', '>= 5.0.0' 7 | pod 'YYImage' 8 | #pod 'YYImage/WebP' 9 | 10 | end 11 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SDWebImage (5.1.0): 3 | - SDWebImage/Core (= 5.1.0) 4 | - SDWebImage/Core (5.1.0) 5 | - YYImage (1.0.4): 6 | - YYImage/Core (= 1.0.4) 7 | - YYImage/Core (1.0.4) 8 | 9 | DEPENDENCIES: 10 | - SDWebImage (>= 5.0.0) 11 | - YYImage 12 | 13 | SPEC REPOS: 14 | https://github.com/cocoapods/specs.git: 15 | - SDWebImage 16 | - YYImage 17 | 18 | SPEC CHECKSUMS: 19 | SDWebImage: fb387001955223213dde14bc08c8b73f371f8d8f 20 | YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54 21 | 22 | PODFILE CHECKSUM: 7d28b9ae8c240bc994d951954252612eb02203f4 23 | 24 | COCOAPODS: 1.7.2 25 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SDWebImage (5.1.0): 3 | - SDWebImage/Core (= 5.1.0) 4 | - SDWebImage/Core (5.1.0) 5 | - YYImage (1.0.4): 6 | - YYImage/Core (= 1.0.4) 7 | - YYImage/Core (1.0.4) 8 | 9 | DEPENDENCIES: 10 | - SDWebImage (>= 5.0.0) 11 | - YYImage 12 | 13 | SPEC REPOS: 14 | https://github.com/cocoapods/specs.git: 15 | - SDWebImage 16 | - YYImage 17 | 18 | SPEC CHECKSUMS: 19 | SDWebImage: fb387001955223213dde14bc08c8b73f371f8d8f 20 | YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54 21 | 22 | PODFILE CHECKSUM: 7d28b9ae8c240bc994d951954252612eb02203f4 23 | 24 | COCOAPODS: 1.7.2 25 | -------------------------------------------------------------------------------- /Pods/SDWebImage/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2018 Olivier Poitrey rs@dailymotion.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Fabrice Aneche 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import 11 | #import "SDWebImageCompat.h" 12 | 13 | /** 14 | You can use switch case like normal enum. It's also recommended to add a default case. You should not assume anything about the raw value. 15 | For custom coder plugin, it can also extern the enum for supported format. See `SDImageCoder` for more detailed information. 16 | */ 17 | typedef NSInteger SDImageFormat NS_TYPED_EXTENSIBLE_ENUM; 18 | static const SDImageFormat SDImageFormatUndefined = -1; 19 | static const SDImageFormat SDImageFormatJPEG = 0; 20 | static const SDImageFormat SDImageFormatPNG = 1; 21 | static const SDImageFormat SDImageFormatGIF = 2; 22 | static const SDImageFormat SDImageFormatTIFF = 3; 23 | static const SDImageFormat SDImageFormatWebP = 4; 24 | static const SDImageFormat SDImageFormatHEIC = 5; 25 | static const SDImageFormat SDImageFormatHEIF = 6; 26 | 27 | /** 28 | NSData category about the image content type and UTI. 29 | */ 30 | @interface NSData (ImageContentType) 31 | 32 | /** 33 | * Return image format 34 | * 35 | * @param data the input image data 36 | * 37 | * @return the image format as `SDImageFormat` (enum) 38 | */ 39 | + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data; 40 | 41 | /** 42 | * Convert SDImageFormat to UTType 43 | * 44 | * @param format Format as SDImageFormat 45 | * @return The UTType as CFStringRef 46 | */ 47 | + (nonnull CFStringRef)sd_UTTypeFromImageFormat:(SDImageFormat)format CF_RETURNS_NOT_RETAINED NS_SWIFT_NAME(sd_UTType(from:)); 48 | 49 | /** 50 | * Convert UTTyppe to SDImageFormat 51 | * 52 | * @param uttype The UTType as CFStringRef 53 | * @return The Format as SDImageFormat 54 | */ 55 | + (SDImageFormat)sd_imageFormatFromUTType:(nonnull CFStringRef)uttype; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/NSImage+Compatibility.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if SD_MAC 12 | 13 | /** 14 | This category is provided to easily write cross-platform(AppKit/UIKit) code. For common usage, see `UIImage+Metadata.h`. 15 | */ 16 | @interface NSImage (Compatibility) 17 | 18 | /** 19 | The underlying Core Graphics image object. This will actually use `CGImageForProposedRect` with the image size. 20 | */ 21 | @property (nonatomic, readonly, nullable) CGImageRef CGImage; 22 | /** 23 | The scale factor of the image. This wil actually use `bestRepresentationForRect` with image size and pixel size to calculate the scale factor. If failed, use the default value 1.0. Should be greater than or equal to 1.0. 24 | */ 25 | @property (nonatomic, readonly) CGFloat scale; 26 | 27 | // These are convenience methods to make AppKit's `NSImage` match UIKit's `UIImage` behavior. The scale factor should be greater than or equal to 1.0. 28 | 29 | /** 30 | Returns an image object with the scale factor and orientation. The representation is created from the Core Graphics image object. 31 | @note The difference between this and `initWithCGImage:size` is that `initWithCGImage:size` will actually create a `NSCGImageSnapshotRep` representation and always use `backingScaleFactor` as scale factor. So we should avoid it and use `NSBitmapImageRep` with `initWithCGImage:` instead. 32 | @note The difference between this and UIKit's `UIImage` equivalent method is the way to process orientation. If the provided image orientation is not equal to Up orientation, this method will firstly rotate the CGImage to the correct orientation to work compatible with `NSImageView`. However, UIKit will not actually rotate CGImage and just store it as `imageOrientation` property. 33 | 34 | @param cgImage A Core Graphics image object 35 | @param scale The image scale factor 36 | @param orientation The orientation of the image data 37 | @return The image object 38 | */ 39 | - (nonnull instancetype)initWithCGImage:(nonnull CGImageRef)cgImage scale:(CGFloat)scale orientation:(CGImagePropertyOrientation)orientation; 40 | 41 | /** 42 | Returns an image object with the scale factor. The representation is created from the image data. 43 | @note The difference between these this and `initWithData:` is that `initWithData:` will always use `backingScaleFactor` as scale factor. 44 | 45 | @param data The image data 46 | @param scale The image scale factor 47 | @return The image object 48 | */ 49 | - (nullable instancetype)initWithData:(nonnull NSData *)data scale:(CGFloat)scale; 50 | 51 | @end 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageRep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if SD_MAC 12 | 13 | /** 14 | A subclass of `NSBitmapImageRep` to fix that GIF loop count issue because `NSBitmapImageRep` will reset `NSImageCurrentFrameDuration` by using `kCGImagePropertyGIFDelayTime` but not `kCGImagePropertyGIFUnclampedDelayTime`. 15 | Built in GIF coder use this instead of `NSBitmapImageRep` for better GIF rendering. If you do not want this, only enable `SDImageIOCoder`, which just call `NSImage` API and actually use `NSBitmapImageRep` for GIF image. 16 | This also support APNG format using `SDImageAPNGCoder`. Which provide full alpha-channel support and the correct duration match the `kCGImagePropertyAPNGUnclampedDelayTime`. 17 | */ 18 | @interface SDAnimatedImageRep : NSBitmapImageRep 19 | 20 | @end 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageAPNGCoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDImageCoder.h" 11 | 12 | /** 13 | Built in coder using ImageIO that supports APNG encoding/decoding 14 | */ 15 | @interface SDImageAPNGCoder : NSObject 16 | 17 | @property (nonatomic, class, readonly, nonnull) SDImageAPNGCoder *sharedCoder; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageCacheConfig.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDImageCacheConfig.h" 10 | #import "SDMemoryCache.h" 11 | #import "SDDiskCache.h" 12 | 13 | static SDImageCacheConfig *_defaultCacheConfig; 14 | static const NSInteger kDefaultCacheMaxDiskAge = 60 * 60 * 24 * 7; // 1 week 15 | 16 | @implementation SDImageCacheConfig 17 | 18 | + (SDImageCacheConfig *)defaultCacheConfig { 19 | static dispatch_once_t onceToken; 20 | dispatch_once(&onceToken, ^{ 21 | _defaultCacheConfig = [SDImageCacheConfig new]; 22 | }); 23 | return _defaultCacheConfig; 24 | } 25 | 26 | - (instancetype)init { 27 | if (self = [super init]) { 28 | _shouldDisableiCloud = YES; 29 | _shouldCacheImagesInMemory = YES; 30 | _shouldUseWeakMemoryCache = YES; 31 | _shouldRemoveExpiredDataWhenEnterBackground = YES; 32 | _diskCacheReadingOptions = 0; 33 | _diskCacheWritingOptions = NSDataWritingAtomic; 34 | _maxDiskAge = kDefaultCacheMaxDiskAge; 35 | _maxDiskSize = 0; 36 | _diskCacheExpireType = SDImageCacheConfigExpireTypeModificationDate; 37 | _memoryCacheClass = [SDMemoryCache class]; 38 | _diskCacheClass = [SDDiskCache class]; 39 | } 40 | return self; 41 | } 42 | 43 | - (id)copyWithZone:(NSZone *)zone { 44 | SDImageCacheConfig *config = [[[self class] allocWithZone:zone] init]; 45 | config.shouldDisableiCloud = self.shouldDisableiCloud; 46 | config.shouldCacheImagesInMemory = self.shouldCacheImagesInMemory; 47 | config.shouldUseWeakMemoryCache = self.shouldUseWeakMemoryCache; 48 | config.shouldRemoveExpiredDataWhenEnterBackground = self.shouldRemoveExpiredDataWhenEnterBackground; 49 | config.diskCacheReadingOptions = self.diskCacheReadingOptions; 50 | config.diskCacheWritingOptions = self.diskCacheWritingOptions; 51 | config.maxDiskAge = self.maxDiskAge; 52 | config.maxDiskSize = self.maxDiskSize; 53 | config.maxMemoryCost = self.maxMemoryCost; 54 | config.maxMemoryCount = self.maxMemoryCount; 55 | config.diskCacheExpireType = self.diskCacheExpireType; 56 | config.fileManager = self.fileManager; // NSFileManager does not conform to NSCopying, just pass the reference 57 | config.memoryCacheClass = self.memoryCacheClass; 58 | config.diskCacheClass = self.diskCacheClass; 59 | 60 | return config; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageCoder.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDImageCoder.h" 10 | 11 | SDImageCoderOption const SDImageCoderDecodeFirstFrameOnly = @"decodeFirstFrameOnly"; 12 | SDImageCoderOption const SDImageCoderDecodeScaleFactor = @"decodeScaleFactor"; 13 | 14 | SDImageCoderOption const SDImageCoderEncodeFirstFrameOnly = @"encodeFirstFrameOnly"; 15 | SDImageCoderOption const SDImageCoderEncodeCompressionQuality = @"encodeCompressionQuality"; 16 | 17 | SDImageCoderOption const SDImageCoderWebImageContext = @"webImageContext"; 18 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageCodersManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDImageCoder.h" 11 | 12 | /** 13 | Global object holding the array of coders, so that we avoid passing them from object to object. 14 | Uses a priority queue behind scenes, which means the latest added coders have the highest priority. 15 | This is done so when encoding/decoding something, we go through the list and ask each coder if they can handle the current data. 16 | That way, users can add their custom coders while preserving our existing prebuilt ones 17 | 18 | Note: the `coders` getter will return the coders in their reversed order 19 | Example: 20 | - by default we internally set coders = `IOCoder`, `GIFCoder`, `APNGCoder` 21 | - calling `coders` will return `@[IOCoder, GIFCoder, APNGCoder]` 22 | - call `[addCoder:[MyCrazyCoder new]]` 23 | - calling `coders` now returns `@[IOCoder, GIFCoder, APNGCoder, MyCrazyCoder]` 24 | 25 | Coders 26 | ------ 27 | A coder must conform to the `SDImageCoder` protocol or even to `SDProgressiveImageCoder` if it supports progressive decoding 28 | Conformance is important because that way, they will implement `canDecodeFromData` or `canEncodeToFormat` 29 | Those methods are called on each coder in the array (using the priority order) until one of them returns YES. 30 | That means that coder can decode that data / encode to that format 31 | */ 32 | @interface SDImageCodersManager : NSObject 33 | 34 | /** 35 | Returns the global shared coders manager instance. 36 | */ 37 | @property (nonatomic, class, readonly, nonnull) SDImageCodersManager *sharedManager; 38 | 39 | /** 40 | All coders in coders manager. The coders array is a priority queue, which means the later added coder will have the highest priority 41 | */ 42 | @property (nonatomic, copy, nullable) NSArray> *coders; 43 | 44 | /** 45 | Add a new coder to the end of coders array. Which has the highest priority. 46 | 47 | @param coder coder 48 | */ 49 | - (void)addCoder:(nonnull id)coder; 50 | 51 | /** 52 | Remove a coder in the coders array. 53 | 54 | @param coder coder 55 | */ 56 | - (void)removeCoder:(nonnull id)coder; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageFrame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | /** 13 | This class is used for creating animated images via `animatedImageWithFrames` in `SDImageCoderHelper`. 14 | @note If you need to specify animated images loop count, use `sd_imageLoopCount` property in `UIImage+Metadata.h`. 15 | */ 16 | @interface SDImageFrame : NSObject 17 | 18 | /** 19 | The image of current frame. You should not set an animated image. 20 | */ 21 | @property (nonatomic, strong, readonly, nonnull) UIImage *image; 22 | /** 23 | The duration of current frame to be displayed. The number is seconds but not milliseconds. You should not set this to zero. 24 | */ 25 | @property (nonatomic, readonly, assign) NSTimeInterval duration; 26 | 27 | /** 28 | Create a frame instance with specify image and duration 29 | 30 | @param image current frame's image 31 | @param duration current frame's duration 32 | @return frame instance 33 | */ 34 | + (instancetype _Nonnull)frameWithImage:(UIImage * _Nonnull)image duration:(NSTimeInterval)duration; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageFrame.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDImageFrame.h" 10 | 11 | @interface SDImageFrame () 12 | 13 | @property (nonatomic, strong, readwrite, nonnull) UIImage *image; 14 | @property (nonatomic, readwrite, assign) NSTimeInterval duration; 15 | 16 | @end 17 | 18 | @implementation SDImageFrame 19 | 20 | + (instancetype)frameWithImage:(UIImage *)image duration:(NSTimeInterval)duration { 21 | SDImageFrame *frame = [[SDImageFrame alloc] init]; 22 | frame.image = image; 23 | frame.duration = duration; 24 | 25 | return frame; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageGIFCoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDImageCoder.h" 11 | 12 | /** 13 | Built in coder using ImageIO that supports animated GIF encoding/decoding 14 | @note `SDImageIOCoder` supports GIF but only as static (will use the 1st frame). 15 | @note Use `SDImageGIFCoder` for fully animated GIFs. For `UIImageView`, it will produce animated `UIImage`(`NSImage` on macOS) for rendering. For `SDAnimatedImageView`, it will use `SDAnimatedImage` for rendering. 16 | @note The recommended approach for animated GIFs is using `SDAnimatedImage` with `SDAnimatedImageView`. It's more performant than `UIImageView` for GIF displaying(especially on memory usage) 17 | */ 18 | @interface SDImageGIFCoder : NSObject 19 | 20 | @property (nonatomic, class, readonly, nonnull) SDImageGIFCoder *sharedCoder; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageGraphics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import 11 | 12 | /** 13 | These following graphics context method are provided to easily write cross-platform(AppKit/UIKit) code. 14 | For UIKit, these methods just call the same method in `UIGraphics.h`. See the documentation for usage. 15 | For AppKit, these methods use `NSGraphicsContext` to create image context and match the behavior like UIKit. 16 | */ 17 | 18 | /// Returns the current graphics context. 19 | FOUNDATION_EXPORT CGContextRef __nullable SDGraphicsGetCurrentContext(void) CF_RETURNS_NOT_RETAINED; 20 | /// Creates a bitmap-based graphics context and makes it the current context. 21 | FOUNDATION_EXPORT void SDGraphicsBeginImageContext(CGSize size); 22 | /// Creates a bitmap-based graphics context with the specified options. 23 | FOUNDATION_EXPORT void SDGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale); 24 | /// Removes the current bitmap-based graphics context from the top of the stack. 25 | FOUNDATION_EXPORT void SDGraphicsEndImageContext(void); 26 | /// Returns an image based on the contents of the current bitmap-based graphics context. 27 | FOUNDATION_EXPORT UIImage * __nullable SDGraphicsGetImageFromCurrentImageContext(void); 28 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageIOCoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDImageCoder.h" 11 | 12 | /** 13 | Built in coder that supports PNG, JPEG, TIFF, includes support for progressive decoding. 14 | 15 | GIF 16 | Also supports static GIF (meaning will only handle the 1st frame). 17 | For a full GIF support, we recommend `SDAnimatedImageView` to keep both CPU and memory balanced. 18 | 19 | HEIC 20 | This coder also supports HEIC format because ImageIO supports it natively. But it depends on the system capabilities, so it won't work on all devices, see: https://devstreaming-cdn.apple.com/videos/wwdc/2017/511tj33587vdhds/511/511_working_with_heif_and_hevc.pdf 21 | Decode(Software): !Simulator && (iOS 11 || tvOS 11 || macOS 10.13) 22 | Decode(Hardware): !Simulator && ((iOS 11 && A9Chip) || (macOS 10.13 && 6thGenerationIntelCPU)) 23 | Encode(Software): macOS 10.13 24 | Encode(Hardware): !Simulator && ((iOS 11 && A10FusionChip) || (macOS 10.13 && 6thGenerationIntelCPU)) 25 | */ 26 | @interface SDImageIOCoder : NSObject 27 | 28 | @property (nonatomic, class, readonly, nonnull) SDImageIOCoder *sharedCoder; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDImageLoadersManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDImageLoader.h" 10 | 11 | /** 12 | A loaders manager to manage multiple loaders 13 | */ 14 | @interface SDImageLoadersManager : NSObject 15 | 16 | /** 17 | Returns the global shared loaders manager instance. By default we will set [`SDWebImageDownloader.sharedDownloader`] into the loaders array. 18 | */ 19 | @property (nonatomic, class, readonly, nonnull) SDImageLoadersManager *sharedManager; 20 | 21 | /** 22 | All image loaders in manager. The loaders array is a priority queue, which means the later added loader will have the highest priority 23 | */ 24 | @property (nonatomic, copy, nullable) NSArray>* loaders; 25 | 26 | /** 27 | Add a new image loader to the end of loaders array. Which has the highest priority. 28 | 29 | @param loader loader 30 | */ 31 | - (void)addLoader:(nonnull id)loader; 32 | 33 | /** 34 | Remove a image loader in the loaders array. 35 | 36 | @param loader loader 37 | */ 38 | - (void)removeLoader:(nonnull id)loader; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDMemoryCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | @class SDImageCacheConfig; 12 | /** 13 | A protocol to allow custom memory cache used in SDImageCache. 14 | */ 15 | @protocol SDMemoryCache 16 | 17 | @required 18 | /** 19 | Create a new memory cache instance with the specify cache config. You can check `maxMemoryCost` and `maxMemoryCount` used for memory cache. 20 | 21 | @param config The cache config to be used to create the cache. 22 | @return The new memory cache instance. 23 | */ 24 | - (nonnull instancetype)initWithConfig:(nonnull SDImageCacheConfig *)config; 25 | 26 | /** 27 | Returns the value associated with a given key. 28 | 29 | @param key An object identifying the value. If nil, just return nil. 30 | @return The value associated with key, or nil if no value is associated with key. 31 | */ 32 | - (nullable id)objectForKey:(nonnull id)key; 33 | 34 | /** 35 | Sets the value of the specified key in the cache (0 cost). 36 | 37 | @param object The object to be stored in the cache. If nil, it calls `removeObjectForKey:`. 38 | @param key The key with which to associate the value. If nil, this method has no effect. 39 | @discussion Unlike an NSMutableDictionary object, a cache does not copy the key 40 | objects that are put into it. 41 | */ 42 | - (void)setObject:(nullable id)object forKey:(nonnull id)key; 43 | 44 | /** 45 | Sets the value of the specified key in the cache, and associates the key-value 46 | pair with the specified cost. 47 | 48 | @param object The object to store in the cache. If nil, it calls `removeObjectForKey`. 49 | @param key The key with which to associate the value. If nil, this method has no effect. 50 | @param cost The cost with which to associate the key-value pair. 51 | @discussion Unlike an NSMutableDictionary object, a cache does not copy the key 52 | objects that are put into it. 53 | */ 54 | - (void)setObject:(nullable id)object forKey:(nonnull id)key cost:(NSUInteger)cost; 55 | 56 | /** 57 | Removes the value of the specified key in the cache. 58 | 59 | @param key The key identifying the value to be removed. If nil, this method has no effect. 60 | */ 61 | - (void)removeObjectForKey:(nonnull id)key; 62 | 63 | /** 64 | Empties the cache immediately. 65 | */ 66 | - (void)removeAllObjects; 67 | 68 | @end 69 | 70 | /** 71 | A memory cache which auto purge the cache on memory warning and support weak cache. 72 | */ 73 | @interface SDMemoryCache : NSCache 74 | 75 | @property (nonatomic, strong, nonnull, readonly) SDImageCacheConfig *config; 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheKeyFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | typedef NSString * _Nullable(^SDWebImageCacheKeyFilterBlock)(NSURL * _Nonnull url); 13 | 14 | /** 15 | This is the protocol for cache key filter. 16 | We can use a block to specify the cache key filter. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using `@convention(block)` to store a block into context options. 17 | */ 18 | @protocol SDWebImageCacheKeyFilter 19 | 20 | - (nullable NSString *)cacheKeyForURL:(nonnull NSURL *)url; 21 | 22 | @end 23 | 24 | /** 25 | A cache key filter class with block. 26 | */ 27 | @interface SDWebImageCacheKeyFilter : NSObject 28 | 29 | - (nonnull instancetype)initWithBlock:(nonnull SDWebImageCacheKeyFilterBlock)block; 30 | + (nonnull instancetype)cacheKeyFilterWithBlock:(nonnull SDWebImageCacheKeyFilterBlock)block; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheKeyFilter.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCacheKeyFilter.h" 10 | 11 | @interface SDWebImageCacheKeyFilter () 12 | 13 | @property (nonatomic, copy, nonnull) SDWebImageCacheKeyFilterBlock block; 14 | 15 | @end 16 | 17 | @implementation SDWebImageCacheKeyFilter 18 | 19 | - (instancetype)initWithBlock:(SDWebImageCacheKeyFilterBlock)block { 20 | self = [super init]; 21 | if (self) { 22 | self.block = block; 23 | } 24 | return self; 25 | } 26 | 27 | + (instancetype)cacheKeyFilterWithBlock:(SDWebImageCacheKeyFilterBlock)block { 28 | SDWebImageCacheKeyFilter *cacheKeyFilter = [[SDWebImageCacheKeyFilter alloc] initWithBlock:block]; 29 | return cacheKeyFilter; 30 | } 31 | 32 | - (NSString *)cacheKeyForURL:(NSURL *)url { 33 | if (!self.block) { 34 | return nil; 35 | } 36 | return self.block(url); 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | typedef NSData * _Nullable(^SDWebImageCacheSerializerBlock)(UIImage * _Nonnull image, NSData * _Nullable data, NSURL * _Nullable imageURL); 13 | 14 | /** 15 | This is the protocol for cache serializer. 16 | We can use a block to specify the cache serializer. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using `@convention(block)` to store a block into context options. 17 | */ 18 | @protocol SDWebImageCacheSerializer 19 | 20 | - (nullable NSData *)cacheDataWithImage:(nonnull UIImage *)image originalData:(nullable NSData *)data imageURL:(nullable NSURL *)imageURL; 21 | 22 | @end 23 | 24 | /** 25 | A cache serializer class with block. 26 | */ 27 | @interface SDWebImageCacheSerializer : NSObject 28 | 29 | - (nonnull instancetype)initWithBlock:(nonnull SDWebImageCacheSerializerBlock)block; 30 | + (nonnull instancetype)cacheSerializerWithBlock:(nonnull SDWebImageCacheSerializerBlock)block; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCacheSerializer.h" 10 | 11 | @interface SDWebImageCacheSerializer () 12 | 13 | @property (nonatomic, copy, nonnull) SDWebImageCacheSerializerBlock block; 14 | 15 | @end 16 | 17 | @implementation SDWebImageCacheSerializer 18 | 19 | - (instancetype)initWithBlock:(SDWebImageCacheSerializerBlock)block { 20 | self = [super init]; 21 | if (self) { 22 | self.block = block; 23 | } 24 | return self; 25 | } 26 | 27 | + (instancetype)cacheSerializerWithBlock:(SDWebImageCacheSerializerBlock)block { 28 | SDWebImageCacheSerializer *cacheSerializer = [[SDWebImageCacheSerializer alloc] initWithBlock:block]; 29 | return cacheSerializer; 30 | } 31 | 32 | - (NSData *)cacheDataWithImage:(UIImage *)image originalData:(NSData *)data imageURL:(nullable NSURL *)imageURL { 33 | if (!self.block) { 34 | return nil; 35 | } 36 | return self.block(image, data, imageURL); 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Jamie Pinkham 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import 11 | 12 | #ifdef __OBJC_GC__ 13 | #error SDWebImage does not support Objective-C Garbage Collection 14 | #endif 15 | 16 | // Seems like TARGET_OS_MAC is always defined (on all platforms). 17 | // To determine if we are running on macOS, use TARGET_OS_OSX in Xcode 8 18 | #if TARGET_OS_OSX 19 | #define SD_MAC 1 20 | #else 21 | #define SD_MAC 0 22 | #endif 23 | 24 | // iOS and tvOS are very similar, UIKit exists on both platforms 25 | // Note: watchOS also has UIKit, but it's very limited 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | #define SD_UIKIT 1 28 | #else 29 | #define SD_UIKIT 0 30 | #endif 31 | 32 | #if TARGET_OS_IOS 33 | #define SD_IOS 1 34 | #else 35 | #define SD_IOS 0 36 | #endif 37 | 38 | #if TARGET_OS_TV 39 | #define SD_TV 1 40 | #else 41 | #define SD_TV 0 42 | #endif 43 | 44 | #if TARGET_OS_WATCH 45 | #define SD_WATCH 1 46 | #else 47 | #define SD_WATCH 0 48 | #endif 49 | 50 | 51 | #if SD_MAC 52 | #import 53 | #ifndef UIImage 54 | #define UIImage NSImage 55 | #endif 56 | #ifndef UIImageView 57 | #define UIImageView NSImageView 58 | #endif 59 | #ifndef UIView 60 | #define UIView NSView 61 | #endif 62 | #ifndef UIColor 63 | #define UIColor NSColor 64 | #endif 65 | #else 66 | #if SD_UIKIT 67 | #import 68 | #endif 69 | #if SD_WATCH 70 | #import 71 | #ifndef UIView 72 | #define UIView WKInterfaceObject 73 | #endif 74 | #ifndef UIImageView 75 | #define UIImageView WKInterfaceImage 76 | #endif 77 | #endif 78 | #endif 79 | 80 | #ifndef NS_ENUM 81 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 82 | #endif 83 | 84 | #ifndef NS_OPTIONS 85 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 86 | #endif 87 | 88 | #ifndef dispatch_main_async_safe 89 | #define dispatch_main_async_safe(block)\ 90 | if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(dispatch_get_main_queue())) {\ 91 | block();\ 92 | } else {\ 93 | dispatch_async(dispatch_get_main_queue(), block);\ 94 | } 95 | #endif 96 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if !__has_feature(objc_arc) 12 | #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag 13 | #endif 14 | 15 | #if !OS_OBJECT_USE_OBJC 16 | #error SDWebImage need ARC for dispatch object 17 | #endif 18 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderConfig.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageDownloaderConfig.h" 10 | 11 | static SDWebImageDownloaderConfig * _defaultDownloaderConfig; 12 | 13 | @implementation SDWebImageDownloaderConfig 14 | 15 | + (SDWebImageDownloaderConfig *)defaultDownloaderConfig { 16 | static dispatch_once_t onceToken; 17 | dispatch_once(&onceToken, ^{ 18 | _defaultDownloaderConfig = [SDWebImageDownloaderConfig new]; 19 | }); 20 | return _defaultDownloaderConfig; 21 | } 22 | 23 | - (instancetype)init { 24 | self = [super init]; 25 | if (self) { 26 | _maxConcurrentDownloads = 6; 27 | _downloadTimeout = 15.0; 28 | _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; 29 | } 30 | return self; 31 | } 32 | 33 | - (id)copyWithZone:(NSZone *)zone { 34 | SDWebImageDownloaderConfig *config = [[[self class] allocWithZone:zone] init]; 35 | config.maxConcurrentDownloads = self.maxConcurrentDownloads; 36 | config.downloadTimeout = self.downloadTimeout; 37 | config.minimumProgressInterval = self.minimumProgressInterval; 38 | config.sessionConfiguration = [self.sessionConfiguration copyWithZone:zone]; 39 | config.operationClass = self.operationClass; 40 | config.executionOrder = self.executionOrder; 41 | config.urlCredential = self.urlCredential; 42 | config.username = self.username; 43 | config.password = self.password; 44 | 45 | return config; 46 | } 47 | 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderRequestModifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSURLRequest * _Nonnull request); 13 | 14 | /** 15 | This is the protocol for downloader request modifier. 16 | We can use a block to specify the downloader request modifier. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using `@convention(block)` to store a block into context options. 17 | */ 18 | @protocol SDWebImageDownloaderRequestModifier 19 | 20 | - (nullable NSURLRequest *)modifiedRequestWithRequest:(nonnull NSURLRequest *)request; 21 | 22 | @end 23 | 24 | /** 25 | A downloader request modifier class with block. 26 | */ 27 | @interface SDWebImageDownloaderRequestModifier : NSObject 28 | 29 | - (nonnull instancetype)initWithBlock:(nonnull SDWebImageDownloaderRequestModifierBlock)block; 30 | + (nonnull instancetype)requestModifierWithBlock:(nonnull SDWebImageDownloaderRequestModifierBlock)block; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderRequestModifier.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageDownloaderRequestModifier.h" 10 | 11 | @interface SDWebImageDownloaderRequestModifier () 12 | 13 | @property (nonatomic, copy, nonnull) SDWebImageDownloaderRequestModifierBlock block; 14 | 15 | @end 16 | 17 | @implementation SDWebImageDownloaderRequestModifier 18 | 19 | - (instancetype)initWithBlock:(SDWebImageDownloaderRequestModifierBlock)block { 20 | self = [super init]; 21 | if (self) { 22 | self.block = block; 23 | } 24 | return self; 25 | } 26 | 27 | + (instancetype)requestModifierWithBlock:(SDWebImageDownloaderRequestModifierBlock)block { 28 | SDWebImageDownloaderRequestModifier *requestModifier = [[SDWebImageDownloaderRequestModifier alloc] initWithBlock:block]; 29 | return requestModifier; 30 | } 31 | 32 | - (NSURLRequest *)modifiedRequestWithRequest:(NSURLRequest *)request { 33 | if (!self.block) { 34 | return nil; 35 | } 36 | return self.block(request); 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageError.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Jamie Pinkham 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import "SDWebImageCompat.h" 11 | 12 | FOUNDATION_EXPORT NSErrorDomain const _Nonnull SDWebImageErrorDomain; 13 | 14 | /// The HTTP status code for invalid download response (NSNumber *) 15 | FOUNDATION_EXPORT NSErrorUserInfoKey const _Nonnull SDWebImageErrorDownloadStatusCodeKey; 16 | 17 | /// SDWebImage error domain and codes 18 | typedef NS_ERROR_ENUM(SDWebImageErrorDomain, SDWebImageError) { 19 | SDWebImageErrorInvalidURL = 1000, // The URL is invalid, such as nil URL or corrupted URL 20 | SDWebImageErrorBadImageData = 1001, // The image data can not be decoded to image, or the image data is empty 21 | SDWebImageErrorCacheNotModified = 1002, // The remote location specify that the cached image is not modified, such as the HTTP response 304 code. It's useful for `SDWebImageRefreshCached` 22 | SDWebImageErrorInvalidDownloadOperation = 2000, // The image download operation is invalid, such as nil operation or unexpected error occur when operation initialized 23 | SDWebImageErrorInvalidDownloadStatusCode = 2001, // The image download response a invalid status code. You can check the status code in error's userInfo under `SDWebImageErrorDownloadStatusCodeKey` 24 | SDWebImageErrorCancelled = 2002, // The image loading operation is cancelled before finished, during either async disk cache query, or waiting before actual network request. For actual network request error, check `NSURLErrorDomain` error domain and code. 25 | }; 26 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageError.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Jamie Pinkham 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import "SDWebImageError.h" 11 | 12 | NSErrorDomain const _Nonnull SDWebImageErrorDomain = @"SDWebImageErrorDomain"; 13 | NSErrorUserInfoKey const _Nonnull SDWebImageErrorDownloadStatusCodeKey = @"SDWebImageErrorDownloadStatusCodeKey"; 14 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | 11 | /// A protocol represents cancelable operation. 12 | @protocol SDWebImageOperation 13 | 14 | - (void)cancel; 15 | 16 | @end 17 | 18 | /// NSOperation conform to `SDWebImageOperation`. 19 | @interface NSOperation (SDWebImageOperation) 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageOptionsProcessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | #import "SDWebImageDefine.h" 12 | 13 | @class SDWebImageOptionsResult; 14 | 15 | typedef SDWebImageOptionsResult * _Nullable(^SDWebImageOptionsProcessorBlock)(NSURL * _Nullable url, SDWebImageOptions options, SDWebImageContext * _Nullable context); 16 | 17 | /** 18 | The options result contains both options and context. 19 | */ 20 | @interface SDWebImageOptionsResult : NSObject 21 | 22 | /** 23 | WebCache options. 24 | */ 25 | @property (nonatomic, assign, readonly) SDWebImageOptions options; 26 | 27 | /** 28 | Context options. 29 | */ 30 | @property (nonatomic, copy, readonly, nullable) SDWebImageContext *context; 31 | 32 | /** 33 | Create a new options result. 34 | 35 | @param options options 36 | @param context context 37 | @return The options result contains both options and context. 38 | */ 39 | - (nonnull instancetype)initWithOptions:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context; 40 | 41 | @end 42 | 43 | /** 44 | This is the protocol for options processor. 45 | Options processor can be used, to control the final result for individual image request's `SDWebImageOptions` and `SDWebImageContext` 46 | Implements the protocol to have a global control for each indivadual image request's option. 47 | */ 48 | @protocol SDWebImageOptionsProcessor 49 | 50 | /** 51 | Return the processed options result for specify image URL, with its options and context 52 | 53 | @param url The URL to the image 54 | @param options A mask to specify options to use for this request 55 | @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. 56 | @return The processed result, contains both options and context 57 | */ 58 | - (nullable SDWebImageOptionsResult *)processedResultForURL:(nullable NSURL *)url 59 | options:(SDWebImageOptions)options 60 | context:(nullable SDWebImageContext *)context; 61 | 62 | @end 63 | 64 | /** 65 | A options processor class with block. 66 | */ 67 | @interface SDWebImageOptionsProcessor : NSObject 68 | 69 | - (nonnull instancetype)initWithBlock:(nonnull SDWebImageOptionsProcessorBlock)block; 70 | + (nonnull instancetype)optionsProcessorWithBlock:(nonnull SDWebImageOptionsProcessorBlock)block; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/SDWebImageOptionsProcessor.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageOptionsProcessor.h" 10 | 11 | @interface SDWebImageOptionsResult () 12 | 13 | @property (nonatomic, assign) SDWebImageOptions options; 14 | @property (nonatomic, copy, nullable) SDWebImageContext *context; 15 | 16 | @end 17 | 18 | @implementation SDWebImageOptionsResult 19 | 20 | - (instancetype)initWithOptions:(SDWebImageOptions)options context:(SDWebImageContext *)context { 21 | self = [super init]; 22 | if (self) { 23 | self.options = options; 24 | self.context = context; 25 | } 26 | return self; 27 | } 28 | 29 | @end 30 | 31 | @interface SDWebImageOptionsProcessor () 32 | 33 | @property (nonatomic, copy, nonnull) SDWebImageOptionsProcessorBlock block; 34 | 35 | @end 36 | 37 | @implementation SDWebImageOptionsProcessor 38 | 39 | - (instancetype)initWithBlock:(SDWebImageOptionsProcessorBlock)block { 40 | self = [super init]; 41 | if (self) { 42 | self.block = block; 43 | } 44 | return self; 45 | } 46 | 47 | + (instancetype)optionsProcessorWithBlock:(SDWebImageOptionsProcessorBlock)block { 48 | SDWebImageOptionsProcessor *optionsProcessor = [[SDWebImageOptionsProcessor alloc] initWithBlock:block]; 49 | return optionsProcessor; 50 | } 51 | 52 | - (SDWebImageOptionsResult *)processedResultForURL:(NSURL *)url options:(SDWebImageOptions)options context:(SDWebImageContext *)context { 53 | if (!self.block) { 54 | return nil; 55 | } 56 | return self.block(url, options, context); 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | /** 12 | UIImage category about force decode feature (avoid Image/IO's lazy decoding during rendering behavior). 13 | */ 14 | @interface UIImage (ForceDecode) 15 | 16 | /** 17 | A bool value indicating whether the image has already been decoded. This can help to avoid extra force decode. 18 | */ 19 | @property (nonatomic, assign) BOOL sd_isDecoded; 20 | 21 | /** 22 | Decode the provided image. This is useful if you want to force decode the image before rendering to improve performance. 23 | 24 | @param image The image to be decoded 25 | @return The decoded image 26 | */ 27 | + (nullable UIImage *)sd_decodedImageWithImage:(nullable UIImage *)image; 28 | 29 | /** 30 | Decode and scale down the provided image 31 | 32 | @param image The image to be decoded 33 | @return The decoded and scaled down image 34 | */ 35 | + (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image; 36 | 37 | /** 38 | Decode and scale down the provided image with limit bytes 39 | 40 | @param image The image to be decoded 41 | @param bytes The limit bytes size. Provide 0 to use the build-in limit. 42 | @return The decoded and scaled down image 43 | */ 44 | + (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image limitBytes:(NSUInteger)bytes; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImage+ForceDecode.h" 10 | #import "SDImageCoderHelper.h" 11 | #import "objc/runtime.h" 12 | 13 | @implementation UIImage (ForceDecode) 14 | 15 | - (BOOL)sd_isDecoded { 16 | NSNumber *value = objc_getAssociatedObject(self, @selector(sd_isDecoded)); 17 | return value.boolValue; 18 | } 19 | 20 | - (void)setSd_isDecoded:(BOOL)sd_isDecoded { 21 | objc_setAssociatedObject(self, @selector(sd_isDecoded), @(sd_isDecoded), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 22 | } 23 | 24 | + (nullable UIImage *)sd_decodedImageWithImage:(nullable UIImage *)image { 25 | if (!image) { 26 | return nil; 27 | } 28 | return [SDImageCoderHelper decodedImageWithImage:image]; 29 | } 30 | 31 | + (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image { 32 | return [self sd_decodedAndScaledDownImageWithImage:image limitBytes:0]; 33 | } 34 | 35 | + (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image limitBytes:(NSUInteger)bytes { 36 | if (!image) { 37 | return nil; 38 | } 39 | return [SDImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:bytes]; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Laurin Brandner 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import "SDWebImageCompat.h" 11 | 12 | /** 13 | This category is just use as a convenience method. For more detail control, use methods in `UIImage+MultiFormat.h` or directlly use `SDImageCoder`. 14 | */ 15 | @interface UIImage (GIF) 16 | 17 | /** 18 | Creates an animated UIImage from an NSData. 19 | This will create animated image if the data is Animated GIF. And will create a static image is the data is Static GIF. 20 | 21 | @param data The GIF data 22 | @return The created image 23 | */ 24 | + (nullable UIImage *)sd_imageWithGIFData:(nullable NSData *)data; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Laurin Brandner 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import "UIImage+GIF.h" 11 | #import "SDImageGIFCoder.h" 12 | 13 | @implementation UIImage (GIF) 14 | 15 | + (nullable UIImage *)sd_imageWithGIFData:(nullable NSData *)data { 16 | if (!data) { 17 | return nil; 18 | } 19 | return [[SDImageGIFCoder sharedCoder] decodedImageWithData:data options:0]; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIImage+MemoryCacheCost.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | /** 12 | UIImage category for memory cache cost. 13 | */ 14 | @interface UIImage (MemoryCacheCost) 15 | 16 | /** 17 | The memory cache cost for specify image used by image cache. The cost function is the bytes size held in memory. 18 | If you set some associated object to `UIImage`, you can set the custom value to indicate the memory cost. 19 | 20 | For `UIImage`, this method return the single frame bytes size when `image.images` is nil for static image. Retuen full frame bytes size when `image.images` is not nil for animated image. 21 | For `NSImage`, this method return the single frame bytes size because `NSImage` does not store all frames in memory. 22 | @note Note that because of the limitations of category this property can get out of sync if you create another instance with CGImage or other methods. 23 | @note For custom animated class conforms to `SDAnimatedImage`, you can override this getter method in your subclass to return a more proper value instead, which representing the current frame's total bytes. 24 | */ 25 | @property (assign, nonatomic) NSUInteger sd_memoryCost; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIImage+MemoryCacheCost.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImage+MemoryCacheCost.h" 10 | #import "objc/runtime.h" 11 | #import "NSImage+Compatibility.h" 12 | 13 | FOUNDATION_STATIC_INLINE NSUInteger SDMemoryCacheCostForImage(UIImage *image) { 14 | CGImageRef imageRef = image.CGImage; 15 | if (!imageRef) { 16 | return 0; 17 | } 18 | NSUInteger bytesPerFrame = CGImageGetBytesPerRow(imageRef) * CGImageGetHeight(imageRef); 19 | NSUInteger frameCount; 20 | #if SD_MAC 21 | frameCount = 1; 22 | #elif SD_UIKIT || SD_WATCH 23 | frameCount = image.images.count > 0 ? image.images.count : 1; 24 | #endif 25 | NSUInteger cost = bytesPerFrame * frameCount; 26 | return cost; 27 | } 28 | 29 | @implementation UIImage (MemoryCacheCost) 30 | 31 | - (NSUInteger)sd_memoryCost { 32 | NSNumber *value = objc_getAssociatedObject(self, @selector(sd_memoryCost)); 33 | NSUInteger memoryCost; 34 | if (value != nil) { 35 | memoryCost = [value unsignedIntegerValue]; 36 | } else { 37 | memoryCost = SDMemoryCacheCostForImage(self); 38 | } 39 | return memoryCost; 40 | } 41 | 42 | - (void)setSd_memoryCost:(NSUInteger)sd_memoryCost { 43 | objc_setAssociatedObject(self, @selector(sd_memoryCost), @(sd_memoryCost), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIImage+Metadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "NSData+ImageContentType.h" 11 | 12 | /** 13 | UIImage category for image metadata, including animation, loop count, format, incremental, etc. 14 | */ 15 | @interface UIImage (Metadata) 16 | 17 | /** 18 | * UIKit: 19 | * For static image format, this value is always 0. 20 | * For animated image format, 0 means infinite looping. 21 | * Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods. 22 | * AppKit: 23 | * NSImage currently only support animated via GIF imageRep unlike UIImage. 24 | * The getter of this property will get the loop count from GIF imageRep 25 | * The setter of this property will set the loop count from GIF imageRep 26 | */ 27 | @property (nonatomic, assign) NSUInteger sd_imageLoopCount; 28 | 29 | /** 30 | * UIKit: 31 | * Check the `images` array property 32 | * AppKit: 33 | * NSImage currently only support animated via GIF imageRep unlike UIImage. It will check the imageRep's frame count. 34 | */ 35 | @property (nonatomic, assign, readonly) BOOL sd_isAnimated; 36 | 37 | /** 38 | * The image format represent the original compressed image data format. 39 | * If you don't manually specify a format, this information is retrieve from CGImage using `CGImageGetUTType`, which may return nil for non-CG based image. At this time it will return `SDImageFormatUndefined` as default value. 40 | * @note Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods. 41 | */ 42 | @property (nonatomic, assign) SDImageFormat sd_imageFormat; 43 | 44 | /** 45 | A bool value indicating whether the image is during incremental decoding and may not contains full pixels. 46 | */ 47 | @property (nonatomic, assign) BOOL sd_isIncremental; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIImage+MultiFormat.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImage+MultiFormat.h" 10 | #import "SDImageCodersManager.h" 11 | 12 | @implementation UIImage (MultiFormat) 13 | 14 | + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data { 15 | return [self sd_imageWithData:data scale:1]; 16 | } 17 | 18 | + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data scale:(CGFloat)scale { 19 | return [self sd_imageWithData:data scale:scale firstFrameOnly:NO]; 20 | } 21 | 22 | + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data scale:(CGFloat)scale firstFrameOnly:(BOOL)firstFrameOnly { 23 | if (!data) { 24 | return nil; 25 | } 26 | SDImageCoderOptions *options = @{SDImageCoderDecodeScaleFactor : @(MAX(scale, 1)), SDImageCoderDecodeFirstFrameOnly : @(firstFrameOnly)}; 27 | return [[SDImageCodersManager sharedManager] decodedImageWithData:data options:options]; 28 | } 29 | 30 | - (nullable NSData *)sd_imageData { 31 | return [self sd_imageDataAsFormat:SDImageFormatUndefined]; 32 | } 33 | 34 | - (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat { 35 | return [self sd_imageDataAsFormat:imageFormat compressionQuality:1]; 36 | } 37 | 38 | - (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat compressionQuality:(double)compressionQuality { 39 | return [self sd_imageDataAsFormat:imageFormat compressionQuality:compressionQuality firstFrameOnly:NO]; 40 | } 41 | 42 | - (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat compressionQuality:(double)compressionQuality firstFrameOnly:(BOOL)firstFrameOnly { 43 | SDImageCoderOptions *options = @{SDImageCoderEncodeCompressionQuality : @(compressionQuality), SDImageCoderEncodeFirstFrameOnly : @(firstFrameOnly)}; 44 | return [[SDImageCodersManager sharedManager] encodedDataWithImage:self format:imageFormat options:options]; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Core/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDWebImageOperation.h" 11 | 12 | /** 13 | These methods are used to support canceling for UIView image loading, it's designed to be used internal but not external. 14 | All the stored operations are weak, so it will be dalloced after image loading finished. If you need to store operations, use your own class to keep a strong reference for them. 15 | */ 16 | @interface UIView (WebCacheOperation) 17 | 18 | /** 19 | * Get the image load operation for key 20 | * 21 | * @param key key for identifying the operations 22 | * @return the image load operation 23 | */ 24 | - (nullable id)sd_imageLoadOperationForKey:(nullable NSString *)key; 25 | 26 | /** 27 | * Set the image load operation (storage in a UIView based weak map table) 28 | * 29 | * @param operation the operation 30 | * @param key key for storing the operation 31 | */ 32 | - (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key; 33 | 34 | /** 35 | * Cancel all operations for the current UIView and key 36 | * 37 | * @param key key for identifying the operations 38 | */ 39 | - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key; 40 | 41 | /** 42 | * Just remove the operations corresponding to the current UIView and key without cancelling them 43 | * 44 | * @param key key for identifying the operations 45 | */ 46 | - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if SD_MAC 12 | 13 | #import "UIImage+Transform.h" 14 | 15 | @interface NSBezierPath (RoundedCorners) 16 | 17 | /** 18 | Convenience way to create a bezier path with the specify rounding corners on macOS. Same as the one on `UIBezierPath`. 19 | */ 20 | + (nonnull instancetype)sd_bezierPathWithRoundedRect:(NSRect)rect byRoundingCorners:(SDRectCorner)corners cornerRadius:(CGFloat)cornerRadius; 21 | 22 | @end 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "NSBezierPath+RoundedCorners.h" 10 | 11 | #if SD_MAC 12 | 13 | @implementation NSBezierPath (RoundedCorners) 14 | 15 | + (instancetype)sd_bezierPathWithRoundedRect:(NSRect)rect byRoundingCorners:(SDRectCorner)corners cornerRadius:(CGFloat)cornerRadius { 16 | NSBezierPath *path = [NSBezierPath bezierPath]; 17 | 18 | CGFloat maxCorner = MIN(NSWidth(rect), NSHeight(rect)) / 2; 19 | 20 | CGFloat topLeftRadius = MIN(maxCorner, (corners & SDRectCornerTopLeft) ? cornerRadius : 0); 21 | CGFloat topRightRadius = MIN(maxCorner, (corners & SDRectCornerTopRight) ? cornerRadius : 0); 22 | CGFloat bottomLeftRadius = MIN(maxCorner, (corners & SDRectCornerBottomLeft) ? cornerRadius : 0); 23 | CGFloat bottomRightRadius = MIN(maxCorner, (corners & SDRectCornerBottomRight) ? cornerRadius : 0); 24 | 25 | NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect)); 26 | NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect)); 27 | NSPoint bottomLeft = NSMakePoint(NSMinX(rect), NSMinY(rect)); 28 | NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect)); 29 | 30 | [path moveToPoint:NSMakePoint(NSMidX(rect), NSMaxY(rect))]; 31 | [path appendBezierPathWithArcFromPoint:topLeft toPoint:bottomLeft radius:topLeftRadius]; 32 | [path appendBezierPathWithArcFromPoint:bottomLeft toPoint:bottomRight radius:bottomLeftRadius]; 33 | [path appendBezierPathWithArcFromPoint:bottomRight toPoint:topRight radius:bottomRightRadius]; 34 | [path appendBezierPathWithArcFromPoint:topRight toPoint:topLeft radius:topRightRadius]; 35 | [path closePath]; 36 | 37 | return path; 38 | } 39 | 40 | @end 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | @class SDAsyncBlockOperation; 12 | typedef void (^SDAsyncBlock)(SDAsyncBlockOperation * __nonnull asyncOperation); 13 | 14 | @interface SDAsyncBlockOperation : NSOperation 15 | 16 | - (nonnull instancetype)initWithBlock:(nonnull SDAsyncBlock)block; 17 | + (nonnull instancetype)blockOperationWithBlock:(nonnull SDAsyncBlock)block; 18 | - (void)complete; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDAsyncBlockOperation.h" 10 | 11 | @interface SDAsyncBlockOperation () 12 | 13 | @property (assign, nonatomic, getter = isExecuting) BOOL executing; 14 | @property (assign, nonatomic, getter = isFinished) BOOL finished; 15 | @property (nonatomic, copy, nonnull) SDAsyncBlock executionBlock; 16 | 17 | @end 18 | 19 | @implementation SDAsyncBlockOperation 20 | 21 | @synthesize executing = _executing; 22 | @synthesize finished = _finished; 23 | 24 | - (nonnull instancetype)initWithBlock:(nonnull SDAsyncBlock)block { 25 | self = [super init]; 26 | if (self) { 27 | self.executionBlock = block; 28 | } 29 | return self; 30 | } 31 | 32 | + (nonnull instancetype)blockOperationWithBlock:(nonnull SDAsyncBlock)block { 33 | SDAsyncBlockOperation *operation = [[SDAsyncBlockOperation alloc] initWithBlock:block]; 34 | return operation; 35 | } 36 | 37 | - (void)start { 38 | if (self.isCancelled) { 39 | return; 40 | } 41 | 42 | [self willChangeValueForKey:@"isExecuting"]; 43 | self.executing = YES; 44 | [self didChangeValueForKey:@"isExecuting"]; 45 | 46 | if (self.executionBlock) { 47 | self.executionBlock(self); 48 | } else { 49 | [self complete]; 50 | } 51 | } 52 | 53 | - (void)cancel { 54 | [super cancel]; 55 | [self complete]; 56 | } 57 | 58 | - (void)complete { 59 | [self willChangeValueForKey:@"isExecuting"]; 60 | [self willChangeValueForKey:@"isFinished"]; 61 | self.executing = NO; 62 | self.finished = YES; 63 | [self didChangeValueForKey:@"isExecuting"]; 64 | [self didChangeValueForKey:@"isFinished"]; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDImageAPNGCoderInternal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDImageAPNGCoder.h" 11 | 12 | @interface SDImageAPNGCoder () 13 | 14 | - (float)sd_frameDurationAtIndex:(NSUInteger)index source:(nonnull CGImageSourceRef)source; 15 | - (NSUInteger)sd_imageLoopCountWithSource:(nonnull CGImageSourceRef)source; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | // Apple parse the Asset Catalog compiled file(`Assets.car`) by CoreUI.framework, however it's a private framework and there are no other ways to directly get the data. So we just process the normal bundle files :) 13 | 14 | @interface SDImageAssetManager : NSObject 15 | 16 | @property (nonatomic, strong, nonnull) NSMapTable *imageTable; 17 | 18 | + (nonnull instancetype)sharedAssetManager; 19 | - (nullable NSString *)getPathForName:(nonnull NSString *)name bundle:(nonnull NSBundle *)bundle preferredScale:(nonnull CGFloat *)scale; 20 | - (nullable UIImage *)imageForName:(nonnull NSString *)name; 21 | - (void)storeImage:(nonnull UIImage *)image forName:(nonnull NSString *)name; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | // This is used for operation management, but not for operation queue execute 13 | @interface SDImageCachesManagerOperation : NSOperation 14 | 15 | @property (nonatomic, assign, readonly) NSUInteger pendingCount; 16 | 17 | - (void)beginWithTotalCount:(NSUInteger)totalCount; 18 | - (void)completeOne; 19 | - (void)done; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDImageCachesManagerOperation.h" 10 | #import "SDInternalMacros.h" 11 | 12 | @implementation SDImageCachesManagerOperation 13 | { 14 | dispatch_semaphore_t _pendingCountLock; 15 | } 16 | 17 | @synthesize executing = _executing; 18 | @synthesize finished = _finished; 19 | @synthesize cancelled = _cancelled; 20 | @synthesize pendingCount = _pendingCount; 21 | 22 | - (instancetype)init { 23 | if (self = [super init]) { 24 | _pendingCountLock = dispatch_semaphore_create(1); 25 | _pendingCount = 0; 26 | } 27 | return self; 28 | } 29 | 30 | - (void)beginWithTotalCount:(NSUInteger)totalCount { 31 | self.executing = YES; 32 | self.finished = NO; 33 | _pendingCount = totalCount; 34 | } 35 | 36 | - (NSUInteger)pendingCount { 37 | SD_LOCK(_pendingCountLock); 38 | NSUInteger pendingCount = _pendingCount; 39 | SD_UNLOCK(_pendingCountLock); 40 | return pendingCount; 41 | } 42 | 43 | - (void)completeOne { 44 | SD_LOCK(_pendingCountLock); 45 | _pendingCount = _pendingCount > 0 ? _pendingCount - 1 : 0; 46 | SD_UNLOCK(_pendingCountLock); 47 | } 48 | 49 | - (void)cancel { 50 | self.cancelled = YES; 51 | [self reset]; 52 | } 53 | 54 | - (void)done { 55 | self.finished = YES; 56 | self.executing = NO; 57 | [self reset]; 58 | } 59 | 60 | - (void)reset { 61 | SD_LOCK(_pendingCountLock); 62 | _pendingCount = 0; 63 | SD_UNLOCK(_pendingCountLock); 64 | } 65 | 66 | - (void)setFinished:(BOOL)finished { 67 | [self willChangeValueForKey:@"isFinished"]; 68 | _finished = finished; 69 | [self didChangeValueForKey:@"isFinished"]; 70 | } 71 | 72 | - (void)setExecuting:(BOOL)executing { 73 | [self willChangeValueForKey:@"isExecuting"]; 74 | _executing = executing; 75 | [self didChangeValueForKey:@"isExecuting"]; 76 | } 77 | 78 | - (void)setCancelled:(BOOL)cancelled { 79 | [self willChangeValueForKey:@"isCancelled"]; 80 | _cancelled = cancelled; 81 | [self didChangeValueForKey:@"isCancelled"]; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDImageGIFCoderInternal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDImageGIFCoder.h" 11 | 12 | @interface SDImageGIFCoder () 13 | 14 | - (float)sd_frameDurationAtIndex:(NSUInteger)index source:(nonnull CGImageSourceRef)source; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDmetamacros.h" 11 | 12 | #ifndef SD_LOCK 13 | #define SD_LOCK(lock) dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER); 14 | #endif 15 | 16 | #ifndef SD_UNLOCK 17 | #define SD_UNLOCK(lock) dispatch_semaphore_signal(lock); 18 | #endif 19 | 20 | #ifndef weakify 21 | #define weakify(...) \ 22 | sd_keywordify \ 23 | metamacro_foreach_cxt(sd_weakify_,, __weak, __VA_ARGS__) 24 | #endif 25 | 26 | #ifndef strongify 27 | #define strongify(...) \ 28 | sd_keywordify \ 29 | _Pragma("clang diagnostic push") \ 30 | _Pragma("clang diagnostic ignored \"-Wshadow\"") \ 31 | metamacro_foreach(sd_strongify_,, __VA_ARGS__) \ 32 | _Pragma("clang diagnostic pop") 33 | #endif 34 | 35 | #define sd_weakify_(INDEX, CONTEXT, VAR) \ 36 | CONTEXT __typeof__(VAR) metamacro_concat(VAR, _weak_) = (VAR); 37 | 38 | #define sd_strongify_(INDEX, VAR) \ 39 | __strong __typeof__(VAR) VAR = metamacro_concat(VAR, _weak_); 40 | 41 | #if DEBUG 42 | #define sd_keywordify autoreleasepool {} 43 | #else 44 | #define sd_keywordify try {} @catch (...) {} 45 | #endif 46 | 47 | #ifndef onExit 48 | #define onExit \ 49 | sd_keywordify \ 50 | __strong sd_cleanupBlock_t metamacro_concat(sd_exitBlock_, __LINE__) __attribute__((cleanup(sd_executeCleanupBlock), unused)) = ^ 51 | #endif 52 | 53 | typedef void (^sd_cleanupBlock_t)(void); 54 | 55 | #if defined(__cplusplus) 56 | extern "C" { 57 | #endif 58 | void sd_executeCleanupBlock (__strong sd_cleanupBlock_t *block); 59 | #if defined(__cplusplus) 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDInternalMacros.h" 10 | 11 | void sd_executeCleanupBlock (__strong sd_cleanupBlock_t *block) { 12 | (*block)(); 13 | } 14 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | @interface SDWeakProxy : NSProxy 13 | 14 | @property (nonatomic, weak, readonly, nullable) id target; 15 | 16 | - (nonnull instancetype)initWithTarget:(nonnull id)target; 17 | + (nonnull instancetype)proxyWithTarget:(nonnull id)target; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWeakProxy.h" 10 | 11 | @implementation SDWeakProxy 12 | 13 | - (instancetype)initWithTarget:(id)target { 14 | _target = target; 15 | return self; 16 | } 17 | 18 | + (instancetype)proxyWithTarget:(id)target { 19 | return [[SDWeakProxy alloc] initWithTarget:target]; 20 | } 21 | 22 | - (id)forwardingTargetForSelector:(SEL)selector { 23 | return _target; 24 | } 25 | 26 | - (void)forwardInvocation:(NSInvocation *)invocation { 27 | void *null = NULL; 28 | [invocation setReturnValue:&null]; 29 | } 30 | 31 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector { 32 | return [NSObject instanceMethodSignatureForSelector:@selector(init)]; 33 | } 34 | 35 | - (BOOL)respondsToSelector:(SEL)aSelector { 36 | return [_target respondsToSelector:aSelector]; 37 | } 38 | 39 | - (BOOL)isEqual:(id)object { 40 | return [_target isEqual:object]; 41 | } 42 | 43 | - (NSUInteger)hash { 44 | return [_target hash]; 45 | } 46 | 47 | - (Class)superclass { 48 | return [_target superclass]; 49 | } 50 | 51 | - (Class)class { 52 | return [_target class]; 53 | } 54 | 55 | - (BOOL)isKindOfClass:(Class)aClass { 56 | return [_target isKindOfClass:aClass]; 57 | } 58 | 59 | - (BOOL)isMemberOfClass:(Class)aClass { 60 | return [_target isMemberOfClass:aClass]; 61 | } 62 | 63 | - (BOOL)conformsToProtocol:(Protocol *)aProtocol { 64 | return [_target conformsToProtocol:aProtocol]; 65 | } 66 | 67 | - (BOOL)isProxy { 68 | return YES; 69 | } 70 | 71 | - (NSString *)description { 72 | return [_target description]; 73 | } 74 | 75 | - (NSString *)debugDescription { 76 | return [_target debugDescription]; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/UIColor+HexString.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | @interface UIColor (HexString) 12 | 13 | /** 14 | Convenience way to get hex string from color. The output should always be 32-bit RGBA hex string like `#00000000`. 15 | */ 16 | @property (nonatomic, copy, readonly, nonnull) NSString *sd_hexString; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/Private/UIColor+HexString.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIColor+HexString.h" 10 | 11 | @implementation UIColor (HexString) 12 | 13 | - (NSString *)sd_hexString { 14 | CGFloat red, green, blue, alpha; 15 | #if SD_UIKIT 16 | if (![self getRed:&red green:&green blue:&blue alpha:&alpha]) { 17 | [self getWhite:&red alpha:&alpha]; 18 | green = red; 19 | blue = red; 20 | } 21 | #else 22 | @try { 23 | [self getRed:&red green:&green blue:&blue alpha:&alpha]; 24 | } 25 | @catch (NSException *exception) { 26 | [self getWhite:&red alpha:&alpha]; 27 | green = red; 28 | blue = red; 29 | } 30 | #endif 31 | 32 | red = roundf(red * 255.f); 33 | green = roundf(green * 255.f); 34 | blue = roundf(blue * 255.f); 35 | alpha = roundf(alpha * 255.f); 36 | 37 | uint hex = ((uint)alpha << 24) | ((uint)red << 16) | ((uint)green << 8) | ((uint)blue); 38 | 39 | return [NSString stringWithFormat:@"#%08x", hex]; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## SDWebImage 5 | 6 | Copyright (c) 2009-2018 Olivier Poitrey rs@dailymotion.com 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is furnished 13 | to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | 27 | 28 | ## YYImage 29 | 30 | The MIT License (MIT) 31 | 32 | Copyright (c) 2015 ibireme 33 | 34 | Permission is hereby granted, free of charge, to any person obtaining a copy 35 | of this software and associated documentation files (the "Software"), to deal 36 | in the Software without restriction, including without limitation the rights 37 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 38 | copies of the Software, and to permit persons to whom the Software is 39 | furnished to do so, subject to the following conditions: 40 | 41 | The above copyright notice and this permission notice shall be included in all 42 | copies or substantial portions of the Software. 43 | 44 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 45 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 46 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 47 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 48 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 49 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 50 | SOFTWARE. 51 | 52 | 53 | Generated by CocoaPods - https://cocoapods.org 54 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_YBImageBrowserDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_YBImageBrowserDemo 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-frameworks-Debug-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework 3 | ${BUILT_PRODUCTS_DIR}/YYImage/YYImage.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-frameworks-Debug-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework 2 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYImage.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-frameworks-Release-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework 3 | ${BUILT_PRODUCTS_DIR}/YYImage/YYImage.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-frameworks-Release-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework 2 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYImage.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_YBImageBrowserDemoVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_YBImageBrowserDemoVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" "${PODS_CONFIGURATION_BUILD_DIR}/YYImage" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/YYImage/YYImage.framework/Headers" 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_LDFLAGS = $(inherited) -l"z" -framework "Accelerate" -framework "AssetsLibrary" -framework "CoreFoundation" -framework "ImageIO" -framework "MobileCoreServices" -framework "QuartzCore" -framework "SDWebImage" -framework "UIKit" -framework "YYImage" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_YBImageBrowserDemo { 2 | umbrella header "Pods-YBImageBrowserDemo-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" "${PODS_CONFIGURATION_BUILD_DIR}/YYImage" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/YYImage/YYImage.framework/Headers" 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_LDFLAGS = $(inherited) -l"z" -framework "Accelerate" -framework "AssetsLibrary" -framework "CoreFoundation" -framework "ImageIO" -framework "MobileCoreServices" -framework "QuartzCore" -framework "SDWebImage" -framework "UIKit" -framework "YYImage" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 5.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SDWebImage : NSObject 3 | @end 4 | @implementation PodsDummy_SDWebImage 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "NSButton+WebCache.h" 14 | #import "NSData+ImageContentType.h" 15 | #import "NSImage+Compatibility.h" 16 | #import "SDAnimatedImage.h" 17 | #import "SDAnimatedImageRep.h" 18 | #import "SDAnimatedImageView+WebCache.h" 19 | #import "SDAnimatedImageView.h" 20 | #import "SDDiskCache.h" 21 | #import "SDImageAPNGCoder.h" 22 | #import "SDImageCache.h" 23 | #import "SDImageCacheConfig.h" 24 | #import "SDImageCacheDefine.h" 25 | #import "SDImageCachesManager.h" 26 | #import "SDImageCoder.h" 27 | #import "SDImageCoderHelper.h" 28 | #import "SDImageCodersManager.h" 29 | #import "SDImageFrame.h" 30 | #import "SDImageGIFCoder.h" 31 | #import "SDImageGraphics.h" 32 | #import "SDImageIOCoder.h" 33 | #import "SDImageLoader.h" 34 | #import "SDImageLoadersManager.h" 35 | #import "SDImageTransformer.h" 36 | #import "SDMemoryCache.h" 37 | #import "SDWebImageCacheKeyFilter.h" 38 | #import "SDWebImageCacheSerializer.h" 39 | #import "SDWebImageCompat.h" 40 | #import "SDWebImageDefine.h" 41 | #import "SDWebImageDownloader.h" 42 | #import "SDWebImageDownloaderConfig.h" 43 | #import "SDWebImageDownloaderOperation.h" 44 | #import "SDWebImageDownloaderRequestModifier.h" 45 | #import "SDWebImageError.h" 46 | #import "SDWebImageIndicator.h" 47 | #import "SDWebImageManager.h" 48 | #import "SDWebImageOperation.h" 49 | #import "SDWebImageOptionsProcessor.h" 50 | #import "SDWebImagePrefetcher.h" 51 | #import "SDWebImageTransition.h" 52 | #import "UIButton+WebCache.h" 53 | #import "UIImage+ForceDecode.h" 54 | #import "UIImage+GIF.h" 55 | #import "UIImage+MemoryCacheCost.h" 56 | #import "UIImage+Metadata.h" 57 | #import "UIImage+MultiFormat.h" 58 | #import "UIImage+Transform.h" 59 | #import "UIImageView+HighlightedWebCache.h" 60 | #import "UIImageView+WebCache.h" 61 | #import "UIView+WebCache.h" 62 | #import "UIView+WebCacheOperation.h" 63 | #import "SDWebImage.h" 64 | 65 | FOUNDATION_EXPORT double SDWebImageVersionNumber; 66 | FOUNDATION_EXPORT const unsigned char SDWebImageVersionString[]; 67 | 68 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage.modulemap: -------------------------------------------------------------------------------- 1 | framework module SDWebImage { 2 | umbrella header "SDWebImage-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_LDFLAGS = $(inherited) -framework "ImageIO" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SDWebImage 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/YYImage/YYImage-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.4 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/YYImage/YYImage-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_YYImage : NSObject 3 | @end 4 | @implementation PodsDummy_YYImage 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/YYImage/YYImage-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/YYImage/YYImage-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "YYAnimatedImageView.h" 14 | #import "YYFrameImage.h" 15 | #import "YYImage.h" 16 | #import "YYImageCoder.h" 17 | #import "YYSpriteSheetImage.h" 18 | 19 | FOUNDATION_EXPORT double YYImageVersionNumber; 20 | FOUNDATION_EXPORT const unsigned char YYImageVersionString[]; 21 | 22 | -------------------------------------------------------------------------------- /Pods/Target Support Files/YYImage/YYImage.modulemap: -------------------------------------------------------------------------------- 1 | framework module YYImage { 2 | umbrella header "YYImage-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/YYImage/YYImage.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/YYImage 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_LDFLAGS = $(inherited) -l"z" -framework "Accelerate" -framework "AssetsLibrary" -framework "CoreFoundation" -framework "ImageIO" -framework "MobileCoreServices" -framework "QuartzCore" -framework "UIKit" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/YYImage 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Pods/YYImage/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 ibireme 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Video/YBIBVideoActionBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBVideoActionBar.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/11. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class YBIBVideoActionBar; 14 | 15 | @protocol YBIBVideoActionBarDelegate 16 | @required 17 | 18 | - (void)yb_videoActionBar:(YBIBVideoActionBar *)actionBar clickPlayButton:(UIButton *)playButton; 19 | 20 | - (void)yb_videoActionBar:(YBIBVideoActionBar *)actionBar clickPauseButton:(UIButton *)pauseButton; 21 | 22 | - (void)yb_videoActionBar:(YBIBVideoActionBar *)actionBar changeValue:(float)value; 23 | 24 | @end 25 | 26 | @interface YBIBVideoActionBar : UIView 27 | 28 | @property (nonatomic, weak) id delegate; 29 | 30 | - (void)setMaxValue:(float)value; 31 | 32 | - (void)setCurrentValue:(float)value; 33 | 34 | - (void)pause; 35 | 36 | - (void)play; 37 | 38 | + (CGFloat)defaultHeight; 39 | 40 | @property (nonatomic, assign, readonly) BOOL isTouchInside; 41 | 42 | @end 43 | 44 | NS_ASSUME_NONNULL_END 45 | -------------------------------------------------------------------------------- /Video/YBIBVideoCell+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBVideoCell+Internal.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/12/23. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBVideoCell.h" 10 | #import "YBIBVideoView.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface YBIBVideoCell () 15 | 16 | @property (nonatomic, strong) YBIBVideoView *videoView; 17 | 18 | @end 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /Video/YBIBVideoCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBVideoCell.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/10. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBCellProtocol.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBVideoCell : UICollectionViewCell 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Video/YBIBVideoData+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBVideoData+Internal.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/11. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBVideoData.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class YBIBVideoData; 14 | 15 | @protocol YBIBVideoDataDelegate 16 | @required 17 | 18 | - (void)yb_startLoadingAVAssetFromPHAssetForData:(YBIBVideoData *)data; 19 | 20 | - (void)yb_finishLoadingAVAssetFromPHAssetForData:(YBIBVideoData *)data; 21 | 22 | - (void)yb_startLoadingFirstFrameForData:(YBIBVideoData *)data; 23 | 24 | - (void)yb_finishLoadingFirstFrameForData:(YBIBVideoData *)data; 25 | 26 | - (void)yb_videoData:(YBIBVideoData *)data downloadingWithProgress:(CGFloat)progress; 27 | 28 | - (void)yb_finishDownloadingForData:(YBIBVideoData *)data; 29 | 30 | - (void)yb_videoData:(YBIBVideoData *)data readyForThumbImage:(UIImage *)image; 31 | 32 | - (void)yb_videoData:(YBIBVideoData *)data readyForAVAsset:(AVAsset *)asset; 33 | 34 | - (void)yb_videoIsInvalidForData:(YBIBVideoData *)data; 35 | 36 | @end 37 | 38 | @interface YBIBVideoData () 39 | 40 | @property (nonatomic, assign, getter=isLoadingAVAssetFromPHAsset) BOOL loadingAVAssetFromPHAsset; 41 | 42 | @property (nonatomic, assign, getter=isLoadingFirstFrame) BOOL loadingFirstFrame; 43 | 44 | @property (nonatomic, assign, getter=isDownloading) BOOL downloading; 45 | 46 | @property (nonatomic, weak) id delegate; 47 | 48 | @end 49 | 50 | NS_ASSUME_NONNULL_END 51 | -------------------------------------------------------------------------------- /Video/YBIBVideoData.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBVideoData.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/10. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "YBIBDataProtocol.h" 11 | #import "YBIBInteractionProfile.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @class YBIBVideoData; 16 | 17 | /// 单击事件的处理闭包 18 | typedef void (^YBIBVideoSingleTouchBlock)(YBIBVideoData *videoData); 19 | 20 | 21 | /** 22 | 图片数据类,承担配置数据和处理数据的责任 23 | */ 24 | @interface YBIBVideoData : NSObject 25 | 26 | /// 视频 URL 27 | @property (nonatomic, copy, nullable) NSURL *videoURL; 28 | 29 | /// 相册视频资源 30 | @property (nonatomic, strong, nullable) PHAsset *videoPHAsset; 31 | 32 | /// 视频 AVAsset (通常使用 AVURLAsset) 33 | @property (nonatomic, strong, nullable) AVAsset *videoAVAsset; 34 | 35 | /// 投影视图,当前数据模型对应外界业务的 UIView (通常为 UIImageView),做转场动效用 36 | @property (nonatomic, weak, nullable) __kindof UIView *projectiveView; 37 | 38 | /// 预览图/缩约图,若 projectiveView 存在且是 UIImageView 类型将会自动获取缩约图 39 | @property (nonatomic, strong, nullable) UIImage *thumbImage; 40 | 41 | /// 是否允许保存到相册 42 | @property (nonatomic, assign) BOOL allowSaveToPhotoAlbum; 43 | 44 | /// 自动播放次数,默认为 0,NSUIntegerMax 表示无限次 45 | @property (nonatomic, assign) NSUInteger autoPlayCount; 46 | 47 | /// 重复播放次数,默认为 0,NSUIntegerMax 表示无限次 48 | @property (nonatomic, assign) NSUInteger repeatPlayCount; 49 | 50 | /// 预留属性可随意使用 51 | @property (nonatomic, strong, nullable) id extraData; 52 | 53 | /// 手势交互动效配置文件 54 | @property (nonatomic, strong) YBIBInteractionProfile *interactionProfile; 55 | 56 | /// 单击的处理(视频未播放时),默认是退出图片浏览器 57 | @property (nonatomic, copy, nullable) YBIBVideoSingleTouchBlock singleTouchBlock; 58 | 59 | /// 是否要隐藏播放时的叉叉(取消)按钮 60 | @property (nonatomic, assign) BOOL shouldHideForkButton; 61 | 62 | @end 63 | 64 | NS_ASSUME_NONNULL_END 65 | -------------------------------------------------------------------------------- /Video/YBIBVideoTopBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBVideoTopBar.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/11. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBVideoTopBar : UIView 14 | 15 | @property (nonatomic, strong, readonly) UIButton *cancelButton; 16 | 17 | + (CGFloat)defaultHeight; 18 | 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /Video/YBIBVideoTopBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBVideoTopBar.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/11. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBVideoTopBar.h" 10 | #import "YBIBIconManager.h" 11 | 12 | @interface YBIBVideoTopBar () 13 | @property (nonatomic, strong) UIButton *cancelButton; 14 | @end 15 | 16 | @implementation YBIBVideoTopBar 17 | 18 | #pragma mark - life cycle 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame { 21 | self = [super initWithFrame:frame]; 22 | if (self) { 23 | [self addSubview:self.cancelButton]; 24 | } 25 | return self; 26 | } 27 | 28 | - (void)layoutSubviews { 29 | [super layoutSubviews]; 30 | CGFloat buttonWidth = 54; 31 | self.cancelButton.frame = CGRectMake(0, 0, buttonWidth, self.bounds.size.height); 32 | } 33 | 34 | #pragma mark - public 35 | 36 | + (CGFloat)defaultHeight { 37 | return 50; 38 | } 39 | 40 | #pragma mark - getter 41 | 42 | - (UIButton *)cancelButton { 43 | if (!_cancelButton) { 44 | _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom]; 45 | [_cancelButton setImage:YBIBIconManager.sharedManager.videoCancelImage() forState:UIControlStateNormal]; 46 | _cancelButton.layer.shadowColor = UIColor.darkGrayColor.CGColor; 47 | _cancelButton.layer.shadowOffset = CGSizeMake(0, 1); 48 | _cancelButton.layer.shadowOpacity = 1; 49 | _cancelButton.layer.shadowRadius = 4; 50 | } 51 | return _cancelButton; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Video/YBIBVideoView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBVideoView.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/11. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBVideoActionBar.h" 10 | #import "YBIBVideoTopBar.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @class YBIBVideoView; 15 | 16 | @protocol YBIBVideoViewDelegate 17 | @required 18 | 19 | - (BOOL)yb_isFreezingForVideoView:(YBIBVideoView *)view; 20 | 21 | - (void)yb_preparePlayForVideoView:(YBIBVideoView *)view; 22 | 23 | - (void)yb_startPlayForVideoView:(YBIBVideoView *)view; 24 | 25 | - (void)yb_finishPlayForVideoView:(YBIBVideoView *)view; 26 | 27 | - (void)yb_didPlayToEndTimeForVideoView:(YBIBVideoView *)view; 28 | 29 | - (void)yb_playFailedForVideoView:(YBIBVideoView *)view; 30 | 31 | - (void)yb_respondsToTapGestureForVideoView:(YBIBVideoView *)view; 32 | 33 | - (void)yb_cancelledForVideoView:(YBIBVideoView *)view; 34 | 35 | - (CGSize)yb_containerSizeForVideoView:(YBIBVideoView *)view; 36 | 37 | - (void)yb_autoPlayCountChanged:(NSUInteger)count; 38 | 39 | @end 40 | 41 | @interface YBIBVideoView : UIView 42 | 43 | @property (nonatomic, strong) UIImageView *thumbImageView; 44 | 45 | @property (nonatomic, weak) id delegate; 46 | 47 | - (void)updateLayoutWithExpectOrientation:(UIDeviceOrientation)orientation containerSize:(CGSize)containerSize; 48 | 49 | @property (nonatomic, strong, nullable) AVAsset *asset; 50 | 51 | @property (nonatomic, assign, readonly, getter=isPlaying) BOOL playing; 52 | 53 | @property (nonatomic, assign, readonly, getter=isPlayFailed) BOOL playFailed; 54 | 55 | @property (nonatomic, assign, readonly, getter=isPreparingPlay) BOOL preparingPlay; 56 | 57 | @property (nonatomic, strong, readonly) UITapGestureRecognizer *tapGesture; 58 | 59 | - (void)reset; 60 | 61 | - (void)hideToolBar:(BOOL)hide; 62 | 63 | - (void)hidePlayButton; 64 | 65 | - (void)preparPlay; 66 | 67 | @property (nonatomic, assign) BOOL needAutoPlay; 68 | 69 | @property (nonatomic, assign) NSUInteger autoPlayCount; 70 | 71 | @property (nonatomic, strong, readonly) YBIBVideoTopBar *topBar; 72 | @property (nonatomic, strong, readonly) YBIBVideoActionBar *actionBar; 73 | 74 | @end 75 | 76 | NS_ASSUME_NONNULL_END 77 | -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_bigPlay@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_bigPlay@2x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_bigPlay@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_bigPlay@3x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_cancel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_cancel@2x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_cancel@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_cancel@3x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_circlePoint@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_circlePoint@2x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_circlePoint@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_circlePoint@3x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_pause@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_pause@2x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_pause@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_pause@3x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_play@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_play@2x.png -------------------------------------------------------------------------------- /Video/YBImageBrowserVideo.bundle/ybib_play@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/Video/YBImageBrowserVideo.bundle/ybib_play@3x.png -------------------------------------------------------------------------------- /YBImageBrowser.podspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | Pod::Spec.new do |s| 4 | 5 | 6 | s.name = "YBImageBrowser" 7 | 8 | s.version = "3.0.9" 9 | 10 | s.summary = "iOS image browser / iOS 图片浏览器" 11 | 12 | s.description = <<-DESC 13 | iOS 图片浏览器,功能强大,易于拓展,极致的性能优化和严格的内存控制让其运行更加的流畅和稳健。 14 | DESC 15 | 16 | s.homepage = "https://github.com/indulgeIn" 17 | 18 | s.license = "MIT" 19 | 20 | s.author = { "杨波" => "1106355439@qq.com" } 21 | 22 | s.platform = :ios, "8.0" 23 | 24 | s.source = { :git => "https://github.com/indulgeIn/YBImageBrowser.git", :tag => "#{s.version}" } 25 | 26 | s.requires_arc = true 27 | 28 | s.default_subspec = "Core" 29 | 30 | s.subspec "Core" do |core| 31 | core.source_files = "YBImageBrowser/**/*.{h,m}" 32 | core.resources = "YBImageBrowser/YBImageBrowser.bundle" 33 | core.dependency 'YYImage' 34 | core.dependency 'SDWebImage', '>= 5.0.0' 35 | end 36 | s.subspec "NOSD" do |core| 37 | core.source_files = "YBImageBrowser/**/*.{h,m}" 38 | core.exclude_files = "YBImageBrowser/WebImageMediator/YBIBDefaultWebImageMediator.{h,m}" 39 | core.resources = "YBImageBrowser/YBImageBrowser.bundle" 40 | core.dependency 'YYImage' 41 | end 42 | 43 | s.subspec "Video" do |video| 44 | video.source_files = "Video/*.{h,m}" 45 | video.resources = "Video/YBImageBrowserVideo.bundle" 46 | video.dependency 'YBImageBrowser/Core' 47 | end 48 | s.subspec "VideoNOSD" do |video| 49 | video.source_files = "Video/*.{h,m}" 50 | video.resources = "Video/YBImageBrowserVideo.bundle" 51 | video.dependency 'YBImageBrowser/NOSD' 52 | end 53 | 54 | end 55 | -------------------------------------------------------------------------------- /YBImageBrowser/AuxiliaryView/YBIBAuxiliaryViewHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBAuxiliaryViewHandler.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/27. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol YBIBAuxiliaryViewHandler 14 | 15 | @required 16 | 17 | /// 展示正确情况的提示 18 | - (void)yb_showCorrectToastWithContainer:(UIView *)container text:(NSString *)text; 19 | /// 展示错误情况的提示 20 | - (void)yb_showIncorrectToastWithContainer:(UIView *)container text:(NSString *)text; 21 | /// 隐藏所有提示 22 | - (void)yb_hideToastWithContainer:(UIView *)container; 23 | 24 | /// 展示加载视图 25 | - (void)yb_showLoadingWithContainer:(UIView *)container; 26 | /// 展示带进度的加载视图 27 | - (void)yb_showLoadingWithContainer:(UIView *)container progress:(CGFloat)progress; 28 | /// 展示带文字的视图 29 | - (void)yb_showLoadingWithContainer:(UIView *)container text:(NSString *)text; 30 | /// 隐藏所有视图 31 | - (void)yb_hideLoadingWithContainer:(UIView *)container; 32 | 33 | @end 34 | 35 | @interface YBIBAuxiliaryViewHandler : NSObject 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /YBImageBrowser/AuxiliaryView/YBIBAuxiliaryViewHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBAuxiliaryViewHandler.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/27. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBAuxiliaryViewHandler.h" 10 | #import "YBIBToastView.h" 11 | #import "YBIBLoadingView.h" 12 | 13 | @implementation YBIBAuxiliaryViewHandler 14 | 15 | #pragma mark - 16 | 17 | - (void)yb_showCorrectToastWithContainer:(UIView *)container text:(NSString *)text { 18 | [container ybib_showHookToast:text]; 19 | } 20 | 21 | - (void)yb_showIncorrectToastWithContainer:(UIView *)container text:(NSString *)text { 22 | [container ybib_showForkToast:text]; 23 | } 24 | 25 | - (void)yb_hideToastWithContainer:(UIView *)container { 26 | [container ybib_hideToast]; 27 | } 28 | 29 | - (void)yb_showLoadingWithContainer:(UIView *)container { 30 | [container ybib_showLoading]; 31 | } 32 | 33 | - (void)yb_showLoadingWithContainer:(UIView *)container progress:(CGFloat)progress { 34 | [container ybib_showLoadingWithProgress:progress]; 35 | } 36 | 37 | - (void)yb_showLoadingWithContainer:(UIView *)container text:(NSString *)text { 38 | [container ybib_showLoadingWithText:text click:nil]; 39 | } 40 | 41 | - (void)yb_hideLoadingWithContainer:(UIView *)container { 42 | [container ybib_hideLoading]; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /YBImageBrowser/AuxiliaryView/YBIBLoadingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBLoadingView.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/9/1. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UIView (YBIBLoading) 14 | 15 | - (void)ybib_showLoading; 16 | 17 | - (void)ybib_showLoadingWithProgress:(CGFloat)progress; 18 | 19 | - (void)ybib_showLoadingWithText:(NSString *)text click:(nullable void(^)(void))click; 20 | 21 | - (void)ybib_hideLoading; 22 | 23 | @end 24 | 25 | 26 | @interface YBIBLoadingView : UIView 27 | 28 | - (void)show; 29 | 30 | - (void)showProgress:(CGFloat)progress; 31 | 32 | - (void)showText:(NSString *)text click:(void(^)(void))click; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /YBImageBrowser/AuxiliaryView/YBIBToastView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBToastView.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/20. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UIView (YBIBToast) 14 | 15 | - (void)ybib_showHookToast:(NSString *)text; 16 | 17 | - (void)ybib_showForkToast:(NSString *)text; 18 | 19 | - (void)ybib_hideToast; 20 | 21 | @end 22 | 23 | 24 | typedef NS_ENUM(NSInteger, YBIBToastType) { 25 | YBIBToastTypeNone, 26 | YBIBToastTypeHook, 27 | YBIBToastTypeFork 28 | }; 29 | 30 | @interface YBIBToastView : UIView 31 | 32 | - (void)showWithText:(NSString *)text type:(YBIBToastType)type; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/NSObject+YBImageBrowser.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+YBImageBrowser.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/9/26. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface NSObject (YBImageBrowser) 14 | 15 | @property (nonatomic, assign) CGFloat ybib_originAlpha; 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/NSObject+YBImageBrowser.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+YBImageBrowser.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/9/26. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "NSObject+YBImageBrowser.h" 10 | #import 11 | 12 | @implementation NSObject (YBImageBrowser) 13 | 14 | static void *YBIBOriginAlphaKey = &YBIBOriginAlphaKey; 15 | - (void)setYbib_originAlpha:(CGFloat)ybib_originAlpha { 16 | objc_setAssociatedObject(self, YBIBOriginAlphaKey, @(ybib_originAlpha), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 17 | } 18 | - (CGFloat)ybib_originAlpha { 19 | NSNumber *alpha = objc_getAssociatedObject(self, YBIBOriginAlphaKey); 20 | return alpha ? alpha.floatValue : 1; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBAnimatedTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBAnimatedTransition.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/6. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol YBIBAnimatedTransition 14 | @required 15 | 16 | - (void)yb_showTransitioningWithContainer:(UIView *)container startView:(nullable __kindof UIView *)startView startImage:(nullable UIImage *)startImage endFrame:(CGRect)endFrame orientation:(UIDeviceOrientation)orientation completion:(void(^)(void))completion; 17 | 18 | - (void)yb_hideTransitioningWithContainer:(UIView *)container startView:(nullable __kindof UIView *)startView endView:(UIView *)endView orientation:(UIDeviceOrientation)orientation completion:(void(^)(void))completion; 19 | 20 | @end 21 | 22 | 23 | typedef NS_ENUM(NSInteger, YBIBTransitionType) { 24 | /// 无动效 25 | YBIBTransitionTypeNone, 26 | /// 渐隐 27 | YBIBTransitionTypeFade, 28 | /// 连贯移动 29 | YBIBTransitionTypeCoherent 30 | }; 31 | 32 | @interface YBIBAnimatedTransition : NSObject 33 | 34 | /// 入场动效类型 35 | @property (nonatomic, assign) YBIBTransitionType showType; 36 | /// 出场动效类型 37 | @property (nonatomic, assign) YBIBTransitionType hideType; 38 | 39 | /// 入场动效持续时间 40 | @property (nonatomic, assign) NSTimeInterval showDuration; 41 | /// 出场动效持续时间 42 | @property (nonatomic, assign) NSTimeInterval hideDuration; 43 | 44 | @end 45 | 46 | NS_ASSUME_NONNULL_END 47 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBCollectionView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBCollectionView.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/6. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBCollectionViewLayout.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBCollectionView : UICollectionView 14 | 15 | @property (nonatomic, strong, readonly) YBIBCollectionViewLayout *layout; 16 | 17 | - (NSString *)reuseIdentifierForCellClass:(Class)cellClass; 18 | 19 | - (nullable UICollectionViewCell *)centerCell; 20 | 21 | - (void)scrollToPage:(NSInteger)page; 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBCollectionViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBCollectionViewLayout.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 杨少 on 2018/4/17. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YBIBCollectionViewLayout : UICollectionViewFlowLayout 12 | 13 | @property (nonatomic, assign) CGFloat distanceBetweenPages; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBCollectionViewLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBCollectionViewLayout.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 杨少 on 2018/4/17. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBCollectionViewLayout.h" 10 | 11 | @implementation YBIBCollectionViewLayout 12 | 13 | - (instancetype)init { 14 | self = [super init]; 15 | if (self) { 16 | self.minimumLineSpacing = 0; 17 | self.minimumInteritemSpacing = 0; 18 | self.sectionInset = UIEdgeInsetsZero; 19 | self.scrollDirection = UICollectionViewScrollDirectionHorizontal; 20 | _distanceBetweenPages = 20; 21 | } 22 | return self; 23 | } 24 | 25 | - (void)prepareLayout { 26 | [super prepareLayout]; 27 | self.itemSize = self.collectionView.bounds.size; 28 | } 29 | 30 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { 31 | NSArray *layoutAttsArray = [[NSArray alloc] initWithArray:[super layoutAttributesForElementsInRect:rect] copyItems:YES]; 32 | CGFloat halfWidth = self.collectionView.bounds.size.width / 2.0; 33 | CGFloat centerX = self.collectionView.contentOffset.x + halfWidth; 34 | [layoutAttsArray enumerateObjectsUsingBlock:^(UICollectionViewLayoutAttributes * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 35 | obj.center = CGPointMake(obj.center.x + (obj.center.x - centerX) / halfWidth * self.distanceBetweenPages / 2, obj.center.y); 36 | }]; 37 | return layoutAttsArray; 38 | } 39 | 40 | - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { 41 | return YES; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBContainerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBContainerView.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/11. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBContainerView : UIView 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBContainerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBContainerView.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/11. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBContainerView.h" 10 | 11 | @implementation YBIBContainerView 12 | 13 | - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { 14 | UIView *originView = [super hitTest:point withEvent:event]; 15 | if ([originView isKindOfClass:self.class]) { 16 | // Continue hit-testing if the view is kind of 'self.class'. 17 | return nil; 18 | } 19 | return originView; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBDataMediator.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBDataMediator.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/6. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBImageBrowser.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBDataMediator : NSObject 14 | 15 | - (instancetype)initWithBrowser:(YBImageBrowser *)browser; 16 | 17 | @property (nonatomic, assign) NSUInteger dataCacheCountLimit; 18 | 19 | - (NSInteger)numberOfCells; 20 | 21 | - (id)dataForCellAtIndex:(NSInteger)index; 22 | 23 | - (void)clear; 24 | 25 | @property (nonatomic, assign) NSUInteger preloadCount; 26 | 27 | - (void)preloadWithPage:(NSInteger)page; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBDataMediator.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBDataMediator.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/6. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBDataMediator.h" 10 | #import "YBImageBrowser+Internal.h" 11 | 12 | @implementation YBIBDataMediator { 13 | __weak YBImageBrowser *_browser; 14 | NSCache> *_dataCache; 15 | } 16 | 17 | #pragma mark - life cycle 18 | 19 | - (instancetype)initWithBrowser:(YBImageBrowser *)browser { 20 | if (self = [super init]) { 21 | _browser = browser; 22 | _dataCache = [NSCache new]; 23 | } 24 | return self; 25 | } 26 | 27 | #pragma mark - public 28 | 29 | - (NSInteger)numberOfCells { 30 | return _browser.dataSource ? [_browser.dataSource yb_numberOfCellsInImageBrowser:_browser] : _browser.dataSourceArray.count; 31 | } 32 | 33 | - (id)dataForCellAtIndex:(NSInteger)index { 34 | if (index < 0 || index > self.numberOfCells - 1) return nil; 35 | 36 | id data = [_dataCache objectForKey:@(index)]; 37 | if (!data) { 38 | data = _browser.dataSource ? [_browser.dataSource yb_imageBrowser:_browser dataForCellAtIndex:index] : _browser.dataSourceArray[index]; 39 | [_dataCache setObject:data forKey:@(index)]; 40 | [_browser implementGetBaseInfoProtocol:data]; 41 | } 42 | return data; 43 | } 44 | 45 | - (void)clear { 46 | [_dataCache removeAllObjects]; 47 | } 48 | 49 | - (void)preloadWithPage:(NSInteger)page { 50 | if (_preloadCount == 0) return; 51 | 52 | NSInteger left = -(_preloadCount / 2), right = _preloadCount - ABS(left); 53 | for (NSInteger i = left; i <= right; ++i) { 54 | if (i == 0) continue; 55 | id targetData = [self dataForCellAtIndex:page + i]; 56 | if ([targetData respondsToSelector:@selector(yb_preload)]) { 57 | [targetData yb_preload]; 58 | } 59 | } 60 | } 61 | 62 | #pragma mark - getters & setters 63 | 64 | - (void)setDataCacheCountLimit:(NSUInteger)dataCacheCountLimit { 65 | _dataCacheCountLimit = dataCacheCountLimit; 66 | _dataCache.countLimit = dataCacheCountLimit; 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBIBScreenRotationHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBScreenRotationHandler.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/8. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBImageBrowser.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBScreenRotationHandler : NSObject 14 | 15 | - (instancetype)initWithBrowser:(YBImageBrowser *)browser; 16 | 17 | - (void)startObserveStatusBarOrientation; 18 | 19 | - (void)startObserveDeviceOrientation; 20 | 21 | - (void)clear; 22 | 23 | - (void)configContainerSize:(CGSize)size; 24 | 25 | - (CGSize)containerSizeWithOrientation:(UIDeviceOrientation)orientation; 26 | 27 | @property (nonatomic, assign, readonly, getter=isRotating) BOOL rotating; 28 | 29 | @property (nonatomic, assign, readonly) UIDeviceOrientation currentOrientation; 30 | 31 | @property (nonatomic, assign) UIInterfaceOrientationMask supportedOrientations; 32 | 33 | @property (nonatomic, assign) NSTimeInterval rotationDuration; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /YBImageBrowser/Base/YBImageBrowser+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBImageBrowser+Internal.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/1. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBImageBrowser.h" 10 | #import "YBIBContainerView.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface YBImageBrowser () 15 | 16 | @property (nonatomic, strong) YBIBContainerView *containerView; 17 | 18 | - (void)implementGetBaseInfoProtocol:(id)obj; 19 | 20 | @property (nonatomic, weak, nullable) NSObject *hiddenProjectiveView; 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /YBImageBrowser/Helper/YBIBCopywriter.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBCopywriter.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/9/13. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, YBIBCopywriterType) { 14 | /// 简体中文 15 | YBIBCopywriterTypeSimplifiedChinese, 16 | /// 英文 17 | YBIBCopywriterTypeEnglish 18 | }; 19 | 20 | /** 21 | 文案管理类 22 | */ 23 | @interface YBIBCopywriter : NSObject 24 | 25 | /** 26 | 唯一有效单例 27 | */ 28 | + (instancetype)sharedCopywriter; 29 | 30 | /// 语言类型 31 | @property (nonatomic, assign) YBIBCopywriterType type; 32 | 33 | #pragma - 以下文案可更改 34 | 35 | @property (nonatomic, copy) NSString *videoIsInvalid; 36 | 37 | @property (nonatomic, copy) NSString *videoError; 38 | 39 | @property (nonatomic, copy) NSString *unableToSave; 40 | 41 | @property (nonatomic, copy) NSString *imageIsInvalid; 42 | 43 | @property (nonatomic, copy) NSString *downloadFailed; 44 | 45 | @property (nonatomic, copy) NSString *getPhotoAlbumAuthorizationFailed; 46 | 47 | @property (nonatomic, copy) NSString *saveToPhotoAlbumSuccess; 48 | 49 | @property (nonatomic, copy) NSString *saveToPhotoAlbumFailed; 50 | 51 | @property (nonatomic, copy) NSString *saveToPhotoAlbum; 52 | 53 | @property (nonatomic, copy) NSString *cancel; 54 | 55 | @end 56 | 57 | NS_ASSUME_NONNULL_END 58 | -------------------------------------------------------------------------------- /YBImageBrowser/Helper/YBIBCopywriter.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBCopywriter.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/9/13. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBCopywriter.h" 10 | 11 | @implementation YBIBCopywriter 12 | 13 | #pragma mark - life cycle 14 | 15 | + (instancetype)sharedCopywriter { 16 | static YBIBCopywriter *copywriter = nil; 17 | static dispatch_once_t onceToken; 18 | dispatch_once(&onceToken, ^{ 19 | copywriter = [YBIBCopywriter new]; 20 | }); 21 | return copywriter; 22 | } 23 | 24 | - (instancetype)init { 25 | self = [super init]; 26 | if (self) { 27 | _type = YBIBCopywriterTypeSimplifiedChinese; 28 | NSArray *appleLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]; 29 | if (appleLanguages && appleLanguages.count > 0) { 30 | NSString *languages = appleLanguages[0]; 31 | if (![languages hasPrefix:@"zh-Hans"]) { 32 | _type = YBIBCopywriterTypeEnglish; 33 | } 34 | } 35 | 36 | [self initCopy]; 37 | } 38 | return self; 39 | } 40 | 41 | #pragma mark - private 42 | 43 | - (void)initCopy { 44 | BOOL en = self.type == YBIBCopywriterTypeEnglish; 45 | 46 | self.videoIsInvalid = en ? @"Video is invalid" : @"视频无效"; 47 | self.videoError = en ? @"Video error" : @"视频错误"; 48 | self.unableToSave = en ? @"Unable to save" : @"无法保存"; 49 | self.imageIsInvalid = en ? @"Image is invalid" : @"图片无效"; 50 | self.downloadFailed = en ? @"Download failed" : @"加载图片失败"; 51 | self.getPhotoAlbumAuthorizationFailed = en ? @"Failed to get album authorization" : @"获取相册权限失败"; 52 | self.saveToPhotoAlbumSuccess = en ? @"Save successful" : @"已保存到系统相册"; 53 | self.saveToPhotoAlbumFailed = en ? @"Save failed" : @"保存失败"; 54 | self.saveToPhotoAlbum = en ? @"Save" : @"保存到相册"; 55 | self.cancel = en ? @"Cancel" : @"取消"; 56 | } 57 | 58 | #pragma mark - public 59 | 60 | - (void)setType:(YBIBCopywriterType)type { 61 | _type = type; 62 | [self initCopy]; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /YBImageBrowser/Helper/YBIBIconManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBIconManager.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/8/29. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UIImage (YBImageBrowser) 14 | 15 | /** 16 | 获取图片便利构造方法 17 | 18 | @param name 图片名字 19 | @param bundle 资源对象 20 | @return 图片实例 21 | */ 22 | + (instancetype)ybib_imageNamed:(NSString *)name bundle:(NSBundle *)bundle; 23 | 24 | @end 25 | 26 | 27 | /// 获取图片闭包 28 | typedef UIImage * _Nullable (^YBIBIconBlock)(void); 29 | 30 | /** 31 | 图标管理类 32 | */ 33 | @interface YBIBIconManager : NSObject 34 | 35 | /** 36 | 唯一有效单例 37 | */ 38 | + (instancetype)sharedManager; 39 | 40 | #pragma - 以下图片可更改 41 | 42 | /// 基本-加载 43 | @property (nonatomic, copy) YBIBIconBlock loadingImage; 44 | 45 | /// 工具视图-保存 46 | @property (nonatomic, copy) YBIBIconBlock toolSaveImage; 47 | /// 工具视图-更多 48 | @property (nonatomic, copy) YBIBIconBlock toolMoreImage; 49 | 50 | /// 视频-播放 51 | @property (nonatomic, copy) YBIBIconBlock videoPlayImage; 52 | /// 视频-暂停 53 | @property (nonatomic, copy) YBIBIconBlock videoPauseImage; 54 | /// 视频-取消 55 | @property (nonatomic, copy) YBIBIconBlock videoCancelImage; 56 | /// 视频-播放大图 57 | @property (nonatomic, copy) YBIBIconBlock videoBigPlayImage; 58 | /// 视频-拖动圆点 59 | @property (nonatomic, copy) YBIBIconBlock videoDragCircleImage; 60 | 61 | @end 62 | 63 | NS_ASSUME_NONNULL_END 64 | -------------------------------------------------------------------------------- /YBImageBrowser/Helper/YBIBPhotoAlbumManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBPhotoAlbumManager.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/8/28. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBPhotoAlbumManager : NSObject 14 | 15 | /** 16 | Get photo album authorization. 17 | */ 18 | + (void)getPhotoAlbumAuthorizationSuccess:(void(^)(void))success failed:(void(^)(void))failed; 19 | 20 | /** 21 | Get 'AVAsset' by 'PHAsset' asynchronously, callback is in child thread. 22 | */ 23 | + (void)getAVAssetWithPHAsset:(PHAsset *)phAsset completion:(void(^)(AVAsset * _Nullable asset))completion; 24 | 25 | /** 26 | Get 'ImageData' by 'PHAsset' synchronously, callback is in child thread. 27 | */ 28 | + (void)getImageDataWithPHAsset:(PHAsset *)phAsset completion:(void(^)(NSData * _Nullable data))completion; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /YBImageBrowser/Helper/YBIBPhotoAlbumManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBPhotoAlbumManager.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/8/28. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBPhotoAlbumManager.h" 10 | #import "YBIBUtilities.h" 11 | 12 | @implementation YBIBPhotoAlbumManager 13 | 14 | + (void)getAVAssetWithPHAsset:(PHAsset *)phAsset completion:(nonnull void (^)(AVAsset * _Nullable))completion { 15 | PHVideoRequestOptions *options = [PHVideoRequestOptions new]; 16 | options.networkAccessAllowed = YES; 17 | [[PHImageManager defaultManager] requestAVAssetForVideo:phAsset options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) { 18 | completion(asset); 19 | }]; 20 | } 21 | 22 | + (void)getImageDataWithPHAsset:(PHAsset *)phAsset completion:(nonnull void (^)(NSData * _Nullable))completion { 23 | PHImageRequestOptions *options = [PHImageRequestOptions new]; 24 | options.networkAccessAllowed = YES; 25 | options.resizeMode = PHImageRequestOptionsResizeModeNone; 26 | // Only when this property is YES, the callback will in child thread. 27 | options.synchronous = YES; 28 | [[PHImageManager defaultManager] requestImageDataForAsset:phAsset options:options resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) { 29 | BOOL complete = ![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey] && ![[info objectForKey:PHImageResultIsDegradedKey] boolValue]; 30 | if (complete && imageData) { 31 | completion(imageData); 32 | } else { 33 | completion(nil); 34 | } 35 | }]; 36 | } 37 | 38 | + (void)getPhotoAlbumAuthorizationSuccess:(void(^)(void))success failed:(void(^)(void))failed { 39 | PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus]; 40 | switch (status) { 41 | case PHAuthorizationStatusDenied: 42 | if (failed) failed(); 43 | break; 44 | case PHAuthorizationStatusRestricted: 45 | if (failed) failed(); 46 | break; 47 | case PHAuthorizationStatusNotDetermined: { 48 | [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status){ 49 | YBIB_DISPATCH_ASYNC_MAIN(^{ 50 | if (status == PHAuthorizationStatusAuthorized) { 51 | if (success) success(); 52 | } else { 53 | if (failed) failed(); 54 | } 55 | }) 56 | }]; 57 | } 58 | break; 59 | case PHAuthorizationStatusAuthorized: 60 | if (success) success(); 61 | break; 62 | } 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /YBImageBrowser/Helper/YBIBSentinel.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBSentinel.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/18. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /** 14 | Thread safe. 15 | */ 16 | @interface YBIBSentinel : NSObject 17 | 18 | /// Returns the current value of the counter. 19 | @property (readonly) int32_t value; 20 | 21 | /** 22 | Increase the value atomically. 23 | @return The new value. 24 | */ 25 | - (int32_t)increase; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /YBImageBrowser/Helper/YBIBSentinel.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBSentinel.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/18. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBSentinel.h" 10 | #import 11 | 12 | @implementation YBIBSentinel { 13 | int32_t _value; 14 | } 15 | 16 | - (int32_t)value { 17 | return _value; 18 | } 19 | 20 | - (int32_t)increase { 21 | return OSAtomicIncrement32(&_value); 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /YBImageBrowser/Helper/YBIBUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBUtilities.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 杨少 on 2018/4/11. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | 14 | #define YBIB_DISPATCH_ASYNC(queue, block)\ 15 | if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) {\ 16 | block();\ 17 | } else {\ 18 | dispatch_async(queue, block);\ 19 | } 20 | 21 | #define YBIB_DISPATCH_ASYNC_MAIN(block) YBIB_DISPATCH_ASYNC(dispatch_get_main_queue(), block) 22 | 23 | 24 | #define YBIB_CODE_EXEC_TIME(KEY, ...) \ 25 | CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent(); \ 26 | __VA_ARGS__ \ 27 | CFAbsoluteTime linkTime = (CFAbsoluteTimeGetCurrent() - startTime); \ 28 | NSLog(@"%@ Time-Consuming: %fms", KEY, linkTime * 1000.0); 29 | 30 | 31 | UIWindow * _Nonnull YBIBNormalWindow(void); 32 | 33 | UIViewController * _Nullable YBIBTopController(void); 34 | UIViewController * _Nullable YBIBTopControllerByWindow(UIWindow *); 35 | 36 | BOOL YBIBLowMemory(void); 37 | 38 | BOOL YBIBIsIphoneXSeries(void); 39 | CGFloat YBIBStatusbarHeight(void); 40 | CGFloat YBIBSafeAreaBottomHeight(void); 41 | 42 | UIImage *YBIBSnapshotView(UIView *); 43 | 44 | /// This is orientation of 'YBImageBrowser' not 'UIDevice'. 45 | UIEdgeInsets YBIBPaddingByBrowserOrientation(UIDeviceOrientation); 46 | 47 | 48 | @interface YBIBUtilities : NSObject 49 | 50 | @end 51 | 52 | NS_ASSUME_NONNULL_END 53 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBImageCache+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBImageCache+Internal.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/13. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBImageCache.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, YBIBImageCacheType) { 14 | YBIBImageCacheTypeOrigin, 15 | YBIBImageCacheTypeCompressed 16 | }; 17 | 18 | /** 19 | Not thread safe. 20 | */ 21 | @interface YBIBImageCache () 22 | 23 | - (void)setImage:(UIImage *)image type:(YBIBImageCacheType)type forKey:(NSString *)key resident:(BOOL)resident; 24 | 25 | - (nullable UIImage *)imageForKey:(NSString *)key type:(YBIBImageCacheType)type; 26 | 27 | - (void)removeForKey:(NSString *)key; 28 | 29 | - (void)removeResidentForKey:(NSString *)key; 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBImageCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBImageCache.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/13. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class YBIBImageCache; 14 | 15 | @interface NSObject (YBIBImageCache) 16 | 17 | /// 图片浏览器持有的图片缓存管理类 18 | @property (nonatomic, strong, readonly) YBIBImageCache *ybib_imageCache; 19 | 20 | @end 21 | 22 | 23 | @interface YBIBImageCache : NSObject 24 | 25 | /// 缓存数量限制(一个单位表示一个 YBIBImageData 产生的所有图片数据) 26 | @property (nonatomic, assign) NSUInteger imageCacheCountLimit; 27 | 28 | @end 29 | 30 | NS_ASSUME_NONNULL_END 31 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBImageCell+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBImageCell+Internal.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/12/23. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBImageCell.h" 10 | #import "YBIBImageScrollView.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface YBIBImageCell () 15 | 16 | @property (nonatomic, strong) YBIBImageScrollView *imageScrollView; 17 | 18 | @property (nonatomic, strong) UIImageView *tailoringImageView; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBImageCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBImageCell.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/5. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBCellProtocol.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBImageCell : UICollectionViewCell 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBImageData+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBImageData+Internal.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/12. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBImageData.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, YBIBImageLoadingStatus) { 14 | YBIBImageLoadingStatusNone, 15 | YBIBImageLoadingStatusCompressing, 16 | YBIBImageLoadingStatusDecoding, 17 | YBIBImageLoadingStatusQuerying, 18 | YBIBImageLoadingStatusProcessing, 19 | YBIBImageLoadingStatusDownloading, 20 | YBIBImageLoadingStatusReadingPHAsset, 21 | }; 22 | 23 | @class YBIBImageData; 24 | 25 | @protocol YBIBImageDataDelegate 26 | @required 27 | 28 | - (void)yb_imageData:(YBIBImageData *)data startLoadingWithStatus:(YBIBImageLoadingStatus)status; 29 | 30 | - (void)yb_imageIsInvalidForData:(YBIBImageData *)data; 31 | 32 | - (void)yb_imageData:(YBIBImageData *)data readyForImage:(__kindof UIImage *)image; 33 | 34 | - (void)yb_imageData:(YBIBImageData *)data readyForThumbImage:(__kindof UIImage *)image; 35 | 36 | - (void)yb_imageData:(YBIBImageData *)data readyForCompressedImage:(__kindof UIImage *)image; 37 | 38 | - (void)yb_imageData:(YBIBImageData *)data downloadProgress:(CGFloat)progress; 39 | 40 | - (void)yb_imageDownloadFailedForData:(YBIBImageData *)data; 41 | 42 | @end 43 | 44 | @interface YBIBImageData () 45 | 46 | @property (nonatomic, weak) id delegate; 47 | 48 | /// The status of asynchronous tasks. 49 | @property (nonatomic, assign) YBIBImageLoadingStatus loadingStatus; 50 | 51 | /// The origin image. 52 | @property (nonatomic, strong) UIImage *originImage; 53 | 54 | /// The image compressed by 'originImage' if need. 55 | @property (nonatomic, strong) UIImage *compressedImage; 56 | 57 | - (BOOL)shouldCompress; 58 | 59 | - (void)cuttingImageToRect:(CGRect)rect complete:(void(^)(UIImage * _Nullable image))complete; 60 | 61 | @end 62 | 63 | NS_ASSUME_NONNULL_END 64 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBImageLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBImageLayout.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/12. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol YBIBImageLayout 14 | @required 15 | 16 | /** 17 | 计算图片展示的位置 18 | 19 | @param containerSize 容器大小 20 | @param imageSize 图片大小 (逻辑像素) 21 | @param orientation 图片浏览器的方向 22 | @return 图片展示的位置 (frame) 23 | */ 24 | - (CGRect)yb_imageViewFrameWithContainerSize:(CGSize)containerSize imageSize:(CGSize)imageSize orientation:(UIDeviceOrientation)orientation; 25 | 26 | /** 27 | 计算最大缩放比例 28 | 29 | @param containerSize 容器大小 30 | @param imageSize 图片大小 (逻辑像素) 31 | @param orientation 图片浏览器的方向 32 | @return 最大缩放比例 33 | */ 34 | - (CGFloat)yb_maximumZoomScaleWithContainerSize:(CGSize)containerSize imageSize:(CGSize)imageSize orientation:(UIDeviceOrientation)orientation; 35 | 36 | @end 37 | 38 | typedef NS_ENUM(NSUInteger, YBIBImageFillType) { 39 | /// 宽度优先填充满 40 | YBIBImageFillTypeFullWidth, 41 | /// 完整显示 42 | YBIBImageFillTypeCompletely 43 | }; 44 | 45 | @interface YBIBImageLayout : NSObject 46 | 47 | /// 纵向的填充方式,默认 YBIBImageFillTypeCompletely 48 | @property (nonatomic, assign) YBIBImageFillType verticalFillType; 49 | 50 | /// 横向的填充方式,默认 YBIBImageFillTypeFullWidth 51 | @property (nonatomic, assign) YBIBImageFillType horizontalFillType; 52 | 53 | /// 最大缩放比例 (必须大于 1 才有效,若不指定内部会自动计算) 54 | @property (nonatomic, assign) CGFloat maxZoomScale; 55 | 56 | /// 自动计算严格缩放比例后,再乘以这个值作为最终缩放比例,默认 1.5 57 | @property (nonatomic, assign) CGFloat zoomScaleSurplus; 58 | 59 | @end 60 | 61 | NS_ASSUME_NONNULL_END 62 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBImageScrollView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBImageScrollView.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/10. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBImage.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, YBIBScrollImageType) { 14 | YBIBScrollImageTypeNone, 15 | YBIBScrollImageTypeOriginal, 16 | YBIBScrollImageTypeCompressed, 17 | YBIBScrollImageTypeThumb 18 | }; 19 | 20 | @interface YBIBImageScrollView : UIScrollView 21 | 22 | - (void)setImage:(__kindof UIImage *)image type:(YBIBScrollImageType)type; 23 | 24 | @property (nonatomic, strong, readonly) YYAnimatedImageView *imageView; 25 | 26 | @property (nonatomic, assign) YBIBScrollImageType imageType; 27 | 28 | - (void)reset; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBImageScrollView.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBImageScrollView.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/10. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBImageScrollView.h" 10 | 11 | @interface YBIBImageScrollView () 12 | @property (nonatomic, strong) YYAnimatedImageView *imageView; 13 | @end 14 | 15 | @implementation YBIBImageScrollView 16 | 17 | #pragma mark - life cycle 18 | 19 | - (instancetype)initWithFrame:(CGRect)frame { 20 | self = [super initWithFrame:frame]; 21 | if (self) { 22 | self.showsHorizontalScrollIndicator = NO; 23 | self.showsVerticalScrollIndicator = NO; 24 | self.decelerationRate = UIScrollViewDecelerationRateFast; 25 | self.maximumZoomScale = 1; 26 | self.minimumZoomScale = 1; 27 | self.alwaysBounceHorizontal = NO; 28 | self.alwaysBounceVertical = NO; 29 | self.layer.masksToBounds = NO; 30 | if (@available(iOS 11.0, *)) { 31 | self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; 32 | } 33 | 34 | [self addSubview:self.imageView]; 35 | } 36 | return self; 37 | } 38 | 39 | #pragma mark - public 40 | 41 | - (void)setImage:(__kindof UIImage *)image type:(YBIBScrollImageType)type { 42 | self.imageView.image = image; 43 | self.imageType = type; 44 | } 45 | 46 | - (void)reset { 47 | self.zoomScale = 1; 48 | self.imageView.image = nil; 49 | self.imageView.frame = CGRectZero; 50 | self.imageType = YBIBScrollImageTypeNone; 51 | } 52 | 53 | #pragma mark - getters 54 | 55 | - (YYAnimatedImageView *)imageView { 56 | if (!_imageView) { 57 | _imageView = [YYAnimatedImageView new]; 58 | _imageView.contentMode = UIViewContentModeScaleAspectFill; 59 | _imageView.layer.masksToBounds = YES; 60 | } 61 | return _imageView; 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBInteractionProfile.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBInteractionProfile.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/30. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBInteractionProfile : NSObject 14 | 15 | /// 是否取消手势交互动效 16 | @property (nonatomic, assign) BOOL disable; 17 | 18 | /// 拖动的距离与最大高度的比例,达到这个比例就会出场 19 | @property (nonatomic, assign) CGFloat dismissScale; 20 | 21 | /// 拖动的速度,达到这个值就会出场 22 | @property (nonatomic, assign) CGFloat dismissVelocityY; 23 | 24 | /// 拖动动效复位时的时长 25 | @property (nonatomic, assign) CGFloat restoreDuration; 26 | 27 | /// 拖动触发手势交互动效的起始距离 28 | @property (nonatomic, assign) CGFloat triggerDistance; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /YBImageBrowser/Image/YBIBInteractionProfile.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBInteractionProfile.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/30. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBInteractionProfile.h" 10 | 11 | @implementation YBIBInteractionProfile 12 | 13 | - (instancetype)init { 14 | self = [super init]; 15 | if (self) { 16 | _disable = NO; 17 | _dismissScale = 0.22; 18 | _dismissVelocityY = 800; 19 | _restoreDuration = 0.15; 20 | _triggerDistance = 3; 21 | } 22 | return self; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /YBImageBrowser/Protocol/YBIBCellProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBCellProtocol.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/5. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBGetBaseInfoProtocol.h" 10 | #import "YBIBOrientationReceiveProtocol.h" 11 | #import "YBIBOperateBrowserProtocol.h" 12 | 13 | @protocol YBIBDataProtocol; 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | @protocol YBIBCellProtocol 18 | 19 | @required 20 | 21 | /// Cell 对应的 Data 22 | @property (nonatomic, strong) id yb_cellData; 23 | 24 | @optional 25 | 26 | /** 27 | 获取前景视图,出入场时需要用这个返回值做动效 28 | 29 | @return 前景视图 30 | */ 31 | - (__kindof UIView *)yb_foregroundView; 32 | 33 | /** 34 | 页码变化了 35 | */ 36 | - (void)yb_pageChanged; 37 | 38 | /// 当前 Cell 的页码 39 | @property (nonatomic, copy) NSInteger(^yb_selfPage)(void); 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /YBImageBrowser/Protocol/YBIBDataProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBDataProtocol.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/5. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBGetBaseInfoProtocol.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol YBIBDataProtocol 14 | 15 | @required 16 | 17 | /** 18 | 当前 Data 对应 Cell 的类类型 19 | 20 | @return Class 类型 21 | */ 22 | - (Class)yb_classOfCell; 23 | 24 | @optional 25 | 26 | /** 27 | 获取投影视图,当前数据模型对应外界业务的 UIView (通常为 UIImageView),做转场动效用 28 | 29 | 这个方法会在做出入场动效时调用,若未实现时将无法进行平滑的入场 30 | 31 | @return 投影视图 32 | */ 33 | - (__kindof UIView *)yb_projectiveView; 34 | 35 | /** 36 | 通过一系列数据,计算并返回图片视图在容器中的 frame 37 | 38 | 这个方法会在做入场动效时调用,若未实现时将无法进行平滑的入场 39 | 40 | @param containerSize 容器大小 41 | @param imageSize 图片大小 (逻辑像素) 42 | @param orientation 图片浏览器的方向 43 | @return 计算好的 frame 44 | */ 45 | - (CGRect)yb_imageViewFrameWithContainerSize:(CGSize)containerSize imageSize:(CGSize)imageSize orientation:(UIDeviceOrientation)orientation; 46 | 47 | /** 48 | 预加载数据,有效的预加载能提高性能,请注意管理内存 49 | */ 50 | - (void)yb_preload; 51 | 52 | /** 53 | 保存到相册 54 | */ 55 | - (void)yb_saveToPhotoAlbum; 56 | 57 | /** 58 | 是否允许保存到相册 59 | */ 60 | - (BOOL)yb_allowSaveToPhotoAlbum; 61 | 62 | @end 63 | 64 | NS_ASSUME_NONNULL_END 65 | -------------------------------------------------------------------------------- /YBImageBrowser/Protocol/YBIBGetBaseInfoProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBGetBaseInfoProtocol.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/23. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "YBIBAuxiliaryViewHandler.h" 11 | #import "YBIBWebImageMediator.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @protocol YBIBGetBaseInfoProtocol 16 | 17 | @optional 18 | 19 | /// 当前的方向 20 | @property (nonatomic, copy) UIDeviceOrientation(^yb_currentOrientation)(void); 21 | 22 | /// 根据方向获取容器大小 23 | @property (nonatomic, copy) CGSize(^yb_containerSize)(UIDeviceOrientation orientation); 24 | 25 | /// 容器视图 (可在上面添加子视图) 26 | @property (nonatomic, weak) UIView *yb_containerView; 27 | 28 | /// 辅助视图处理器 29 | @property (nonatomic, copy) id(^yb_auxiliaryViewHandler)(void); 30 | 31 | /// 图片下载缓存相关中介者 32 | @property (nonatomic, copy) id(^yb_webImageMediator)(void); 33 | 34 | /// 当前页码 35 | @property (nonatomic, copy) NSInteger(^yb_currentPage)(void); 36 | 37 | /// 总页码数量 38 | @property (nonatomic, copy) NSInteger(^yb_totalPage)(void); 39 | 40 | /// 判断当前展示的 cell 是否恰好在屏幕中间 41 | @property (nonatomic, copy) BOOL(^yb_cellIsInCenter)(void); 42 | 43 | /// 是否正在转场 44 | @property (nonatomic, copy) BOOL(^yb_isTransitioning)(void); 45 | /// 是否正在展示过程转场 46 | @property (nonatomic, copy) BOOL(^yb_isShowTransitioning)(void); 47 | /// 是否正在隐藏过程转场 48 | @property (nonatomic, copy) BOOL(^yb_isHideTransitioning)(void); 49 | 50 | /// 是否正在旋转 51 | @property (nonatomic, copy) BOOL(^yb_isRotating)(void); 52 | 53 | /// 背景视图 (也就是 YBImageBrower 对象,不可在上面添加子视图。作用:一是可以更改透明度和颜色,入场和出场动效有用;二是可以用来比较内存指针,在做不同实例差异化功能时可能有用,虽然不提倡这么做) 54 | @property (nonatomic, weak) __kindof UIView *yb_backView; 55 | 56 | /// 集合视图 57 | @property (nonatomic, copy) __kindof UICollectionView *(^yb_collectionView)(void); 58 | 59 | @end 60 | 61 | NS_ASSUME_NONNULL_END 62 | -------------------------------------------------------------------------------- /YBImageBrowser/Protocol/YBIBOperateBrowserProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBOperateBrowserProtocol.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/8. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol YBIBOperateBrowserProtocol 14 | 15 | @optional 16 | 17 | /// 隐藏图片浏览器 18 | @property (nonatomic, copy) void(^yb_hideBrowser)(void); 19 | 20 | /// 是否隐藏状态栏 21 | @property (nonatomic, copy) void(^yb_hideStatusBar)(BOOL); 22 | 23 | /// 是否隐藏工具视图 24 | @property (nonatomic, copy) void(^yb_hideToolViews)(BOOL); 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /YBImageBrowser/Protocol/YBIBOrientationReceiveProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBOrientationReceiveProtocol.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/8. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol YBIBOrientationReceiveProtocol 14 | 15 | @optional 16 | 17 | /** 18 | 图片浏览器的方向将要变化 19 | 20 | @param orientation 期望的方向 21 | */ 22 | - (void)yb_orientationWillChangeWithExpectOrientation:(UIDeviceOrientation)orientation; 23 | 24 | /** 25 | 图片浏览器的方向变化动效调用,实现的变化会自动转换为动画 26 | 27 | @param orientation 期望的方向 28 | */ 29 | - (void)yb_orientationChangeAnimationWithExpectOrientation:(UIDeviceOrientation)orientation; 30 | 31 | /** 32 | 图片浏览器的方向已经变化 33 | 34 | @param orientation 当前的方向 35 | */ 36 | - (void)yb_orientationDidChangedWithOrientation:(UIDeviceOrientation)orientation; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /YBImageBrowser/Protocol/YBImageBrowserDataSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBImageBrowserDataSource.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/8/25. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBDataProtocol.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class YBImageBrowser; 14 | 15 | @protocol YBImageBrowserDataSource 16 | 17 | @required 18 | 19 | /** 20 | 返回数据源数量 21 | 22 | @param imageBrowser 图片浏览器 23 | @return 数量 24 | */ 25 | - (NSInteger)yb_numberOfCellsInImageBrowser:(YBImageBrowser *)imageBrowser; 26 | 27 | /** 28 | 返回当前下标对应的数据 29 | 30 | @param imageBrowser 图片浏览器 31 | @param index 当前下标 32 | @return 数据 33 | */ 34 | - (id)yb_imageBrowser:(YBImageBrowser *)imageBrowser dataForCellAtIndex:(NSInteger)index; 35 | 36 | @end 37 | 38 | NS_ASSUME_NONNULL_END 39 | -------------------------------------------------------------------------------- /YBImageBrowser/Protocol/YBImageBrowserDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBImageBrowserDelegate.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/9. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "YBIBDataProtocol.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class YBImageBrowser; 14 | 15 | @protocol YBImageBrowserDelegate 16 | 17 | @optional 18 | 19 | /** 20 | 页码变化 21 | 22 | @param imageBrowser 图片浏览器 23 | @param page 当前页码 24 | @param data 数据 25 | */ 26 | - (void)yb_imageBrowser:(YBImageBrowser *)imageBrowser pageChanged:(NSInteger)page data:(id)data; 27 | 28 | /** 29 | 响应长按手势(若实现该方法将阻止其它地方捕获到长按事件) 30 | 31 | @param imageBrowser 图片浏览器 32 | @param data 数据 33 | */ 34 | - (void)yb_imageBrowser:(YBImageBrowser *)imageBrowser respondsToLongPressWithData:(id)data; 35 | 36 | /** 37 | 开始转场 38 | 39 | @param imageBrowser 图片浏览器 40 | @param isShow YES 表示入场,NO 表示出场 41 | */ 42 | - (void)yb_imageBrowser:(YBImageBrowser *)imageBrowser beginTransitioningWithIsShow:(BOOL)isShow; 43 | 44 | /** 45 | 结束转场 46 | 47 | @param imageBrowser 图片浏览器 48 | @param isShow YES 表示入场,NO 表示出场 49 | */ 50 | - (void)yb_imageBrowser:(YBImageBrowser *)imageBrowser endTransitioningWithIsShow:(BOOL)isShow; 51 | 52 | @end 53 | 54 | NS_ASSUME_NONNULL_END 55 | -------------------------------------------------------------------------------- /YBImageBrowser/ToolView/YBIBSheetView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBSheetView.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/6. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol YBIBDataProtocol; 14 | 15 | typedef void(^YBIBSheetActionBlock)(id data); 16 | 17 | @interface YBIBSheetAction : NSObject 18 | 19 | /// 显示的名字 20 | @property (nonatomic, copy) NSString *name; 21 | 22 | /// 点击回调闭包 23 | @property (nonatomic, copy, nullable) YBIBSheetActionBlock action; 24 | 25 | + (instancetype)actionWithName:(NSString *)name action:(_Nullable YBIBSheetActionBlock)action; 26 | 27 | @end 28 | 29 | 30 | @interface YBIBSheetView : UIView 31 | 32 | /// 数据源 (可自定义添加) 33 | @property (nonatomic, strong) NSMutableArray *actions; 34 | 35 | /// 列表 Cell 的高度 36 | @property (nonatomic, assign) CGFloat cellHeight; 37 | 38 | /// 列表最大高度与容器高度的比例 39 | @property (nonatomic, assign) CGFloat maxHeightScale; 40 | 41 | /// 取消的文本 42 | @property (nonatomic, copy) NSString *cancelText; 43 | 44 | /// 显示动画持续时间 45 | @property (nonatomic, assign) NSTimeInterval showDuration; 46 | 47 | /// 隐藏动画持续时间 48 | @property (nonatomic, assign) NSTimeInterval hideDuration; 49 | 50 | /// 背景透明度 51 | @property (nonatomic, assign) CGFloat backAlpha; 52 | 53 | /** 54 | 展示 55 | 56 | @param view 指定父视图 57 | @param orientation 当前方向 58 | */ 59 | - (void)showToView:(UIView *)view orientation:(UIDeviceOrientation)orientation; 60 | 61 | /** 62 | 隐藏 63 | 64 | @param animation 是否带动画 65 | */ 66 | - (void)hideWithAnimation:(BOOL)animation; 67 | 68 | /// 获取当前数据的闭包 69 | @property (nonatomic, copy) id(^currentdata)(void); 70 | 71 | @end 72 | 73 | NS_ASSUME_NONNULL_END 74 | -------------------------------------------------------------------------------- /YBImageBrowser/ToolView/YBIBToolViewHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBToolViewHandler.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/7. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBSheetView.h" 10 | #import "YBIBTopView.h" 11 | #import "YBIBDataProtocol.h" 12 | #import "YBIBOrientationReceiveProtocol.h" 13 | #import "YBIBOperateBrowserProtocol.h" 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | @protocol YBIBToolViewHandler 18 | 19 | @required 20 | 21 | /** 22 | 容器视图准备好了,可进行子视图的添加和布局 23 | */ 24 | - (void)yb_containerViewIsReadied; 25 | 26 | /** 27 | 隐藏视图 28 | 29 | @param hide 是否隐藏 30 | */ 31 | - (void)yb_hide:(BOOL)hide; 32 | 33 | @optional 34 | 35 | /// 当前数据 36 | @property (nonatomic, copy) id(^yb_currentData)(void); 37 | 38 | /** 39 | 页码变化了 40 | */ 41 | - (void)yb_pageChanged; 42 | 43 | /** 44 | 偏移量变化了 45 | 46 | @param offsetX 当前偏移量 47 | */ 48 | - (void)yb_offsetXChanged:(CGFloat)offsetX; 49 | 50 | /** 51 | 响应长按手势 52 | */ 53 | - (void)yb_respondsToLongPress; 54 | 55 | @end 56 | 57 | @interface YBIBToolViewHandler : NSObject 58 | 59 | /// 弹出表单视图 60 | @property (nonatomic, strong, readonly) YBIBSheetView *sheetView; 61 | 62 | /// 顶部显示页码视图 63 | @property (nonatomic, strong, readonly) YBIBTopView *topView; 64 | 65 | @end 66 | 67 | NS_ASSUME_NONNULL_END 68 | -------------------------------------------------------------------------------- /YBImageBrowser/ToolView/YBIBTopView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBTopView.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/6. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, YBIBTopViewOperationType) { 14 | YBIBTopViewOperationTypeSave, //保存 15 | YBIBTopViewOperationTypeMore //更多 16 | }; 17 | 18 | @interface YBIBTopView : UIView 19 | 20 | /// 页码标签 21 | @property (nonatomic, strong, readonly) UILabel *pageLabel; 22 | 23 | /// 操作按钮(自定义:直接修改图片或文字,然后添加点击事件) 24 | @property (nonatomic, strong, readonly) UIButton *operationButton; 25 | 26 | /// 按钮类型 27 | @property (nonatomic, assign) YBIBTopViewOperationType operationType; 28 | 29 | /** 30 | 设置页码 31 | 32 | @param page 当前页码 33 | @param totalPage 总页码数 34 | */ 35 | - (void)setPage:(NSInteger)page totalPage:(NSInteger)totalPage; 36 | 37 | /// 点击操作按钮的回调 38 | @property (nonatomic, copy) void(^clickOperation)(YBIBTopViewOperationType type); 39 | 40 | + (CGFloat)defaultHeight; 41 | 42 | @end 43 | 44 | NS_ASSUME_NONNULL_END 45 | -------------------------------------------------------------------------------- /YBImageBrowser/WebImageMediator/YBIBDefaultWebImageMediator.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBDefaultWebImageMediator.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/8/27. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "YBIBWebImageMediator.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YBIBDefaultWebImageMediator : NSObject 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowser/WebImageMediator/YBIBWebImageMediator.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBIBWebImageMediator.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/8/27. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NSURLRequest * _Nullable (^YBIBWebImageRequestModifierBlock)(NSURLRequest *request); 14 | typedef void(^YBIBWebImageProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); 15 | typedef void(^YBIBWebImageSuccessBlock)(NSData * _Nullable imageData, BOOL finished); 16 | typedef void(^YBIBWebImageFailedBlock)(NSError * _Nullable error, BOOL finished); 17 | typedef void(^YBIBWebImageCacheQueryCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable imageData); 18 | 19 | @protocol YBIBWebImageMediator 20 | 21 | @required 22 | 23 | /** 24 | 下载图片 25 | 26 | @param URL 图片地址 27 | @param requestModifier 修改默认 NSURLRequest 的闭包 28 | @param progress 进度回调 29 | @param success 成功回调 30 | @param failed 失败回调 31 | @return 下载 token (可为空) 32 | */ 33 | - (id)yb_downloadImageWithURL:(NSURL *)URL requestModifier:(nullable YBIBWebImageRequestModifierBlock)requestModifier progress:(YBIBWebImageProgressBlock)progress success:(YBIBWebImageSuccessBlock)success failed:(YBIBWebImageFailedBlock)failed; 34 | 35 | /** 36 | 缓存图片数据到磁盘 37 | 38 | @param data 图片数据 39 | @param key 缓存标识 40 | */ 41 | - (void)yb_storeToDiskWithImageData:(nullable NSData *)data forKey:(NSURL *)key; 42 | 43 | /** 44 | 读取图片数据 45 | 46 | @param key 缓存标识 47 | @param completed 读取回调 48 | */ 49 | - (void)yb_queryCacheOperationForKey:(NSURL *)key completed:(YBIBWebImageCacheQueryCompletedBlock)completed; 50 | 51 | @optional 52 | 53 | /** 54 | 取消下载 55 | 56 | @param token 下载 token 57 | */ 58 | - (void)yb_cancelTaskWithDownloadToken:(id)token; 59 | 60 | @end 61 | 62 | NS_ASSUME_NONNULL_END 63 | -------------------------------------------------------------------------------- /YBImageBrowser/YBImageBrowser.bundle/ybib_loading@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowser/YBImageBrowser.bundle/ybib_loading@2x.png -------------------------------------------------------------------------------- /YBImageBrowser/YBImageBrowser.bundle/ybib_loading@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowser/YBImageBrowser.bundle/ybib_loading@3x.png -------------------------------------------------------------------------------- /YBImageBrowser/YBImageBrowser.bundle/ybib_more@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowser/YBImageBrowser.bundle/ybib_more@2x.png -------------------------------------------------------------------------------- /YBImageBrowser/YBImageBrowser.bundle/ybib_more@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowser/YBImageBrowser.bundle/ybib_more@3x.png -------------------------------------------------------------------------------- /YBImageBrowser/YBImageBrowser.bundle/ybib_save@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowser/YBImageBrowser.bundle/ybib_save@2x.png -------------------------------------------------------------------------------- /YBImageBrowser/YBImageBrowser.bundle/ybib_save@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowser/YBImageBrowser.bundle/ybib_save@3x.png -------------------------------------------------------------------------------- /YBImageBrowserDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YBImageBrowserDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YBImageBrowserDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /YBImageBrowserDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YBImageBrowserDemo.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/5. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/5. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "MainController.h" 11 | #import "MainNavigationController.h" 12 | 13 | @interface AppDelegate () 14 | 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 21 | MainController *vc = [MainController new]; 22 | 23 | MainNavigationController *nvc = [[MainNavigationController alloc] initWithRootViewController:vc]; 24 | nvc.navigationBar.translucent = NO; 25 | 26 | _window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 27 | _window.rootViewController = nvc; 28 | [_window makeKeyAndVisible]; 29 | return YES; 30 | } 31 | 32 | - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 33 | return UIInterfaceOrientationMaskAll; 34 | } 35 | 36 | - (void)applicationWillResignActive:(UIApplication *)application { 37 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 38 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 39 | } 40 | 41 | 42 | - (void)applicationDidEnterBackground:(UIApplication *)application { 43 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 44 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 45 | } 46 | 47 | 48 | - (void)applicationWillEnterForeground:(UIApplication *)application { 49 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 50 | } 51 | 52 | 53 | - (void)applicationDidBecomeActive:(UIApplication *)application { 54 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 55 | } 56 | 57 | 58 | - (void)applicationWillTerminate:(UIApplication *)application { 59 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 60 | } 61 | 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /YBImageBrowserDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YBImageBrowserDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/Base/BaseListCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseListCell.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BaseListCell : UICollectionViewCell 14 | 15 | @property (nonatomic, strong) id data; 16 | 17 | @property (weak, nonatomic) IBOutlet UIImageView *contentImgView; 18 | 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/Base/BaseListController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseListController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BaseFileManager.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface BaseListController : UIViewController 15 | 16 | @property (nonatomic, copy) NSArray *dataArray; 17 | 18 | - (id)viewAtIndex:(NSInteger)index; 19 | 20 | #pragma - override 21 | 22 | + (NSString *)yb_title; 23 | 24 | - (void)selectedIndex:(NSInteger)index; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/File/BaseFileManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseFileManager.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BaseFileManager : NSObject 14 | 15 | + (NSArray *)imageURLs; 16 | 17 | + (NSArray *)imageNames; 18 | 19 | + (NSArray *)videos; 20 | 21 | + (NSArray *)imagePHAssets; 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/File/BaseFileManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseFileManager.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "BaseFileManager.h" 10 | 11 | @implementation BaseFileManager 12 | 13 | + (NSArray *)imageURLs { 14 | NSString *path = [[NSBundle mainBundle] pathForResource:@"ImageURLs" ofType:@"plist"]; 15 | NSArray *array = [NSArray arrayWithContentsOfFile:path]; 16 | return array; 17 | } 18 | 19 | + (NSArray *)imageNames { 20 | return @[@"localImage1.gif", @"localImage0.jpg", @"localBigImage0.jpeg", @"localLongImage0.jpeg"]; 21 | } 22 | 23 | + (NSArray *)videos { 24 | return @[@"localVideo0.mp4", @"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200ff00000bdkpfpdd2r6fb5kf6m50&line=0.mp4"]; 25 | } 26 | 27 | + (NSArray *)imagePHAssets { 28 | return [self getPHAssets]; 29 | } 30 | 31 | + (NSArray *)getPHAssets { 32 | NSMutableArray *resultArray = [NSMutableArray array]; 33 | PHFetchResult *smartAlbumsFetchResult0 = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary options:nil]; 34 | [smartAlbumsFetchResult0 enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(PHAssetCollection *_Nonnull collection, NSUInteger idx, BOOL * _Nonnull stop) { 35 | NSArray *assets = [self getAssetsInAssetCollection:collection]; 36 | [resultArray addObjectsFromArray:assets]; 37 | }]; 38 | 39 | PHFetchResult *smartAlbumsFetchResult1 = [PHAssetCollection fetchTopLevelUserCollectionsWithOptions:nil]; 40 | [smartAlbumsFetchResult1 enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(PHAssetCollection * _Nonnull collection, NSUInteger idx, BOOL *stop) { 41 | NSArray *assets = [self getAssetsInAssetCollection:collection]; 42 | [resultArray addObjectsFromArray:assets]; 43 | }]; 44 | 45 | return resultArray; 46 | } 47 | 48 | + (NSArray *)getAssetsInAssetCollection:(PHAssetCollection *)assetCollection { 49 | NSMutableArray *arr = [NSMutableArray array]; 50 | PHFetchResult *result = [PHAsset fetchAssetsInAssetCollection:assetCollection options:nil]; 51 | [result enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(PHAsset *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 52 | if (obj.mediaType == PHAssetMediaTypeImage) { 53 | [arr addObject:obj]; 54 | } else if (obj.mediaType == PHAssetMediaTypeVideo) { 55 | [arr addObject:obj]; 56 | } 57 | }]; 58 | return arr; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/File/ImageURLs.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | http://attachments.gfan.com/forum/attachments2/day_120501/1205012009f594464a3d69a145.jpg 6 | https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1563251679757&di=5d148316a23972ec8d20b946b9fe0d6b&imgtype=0&src=http%3A%2F%2Fimages6.fanpop.com%2Fimage%2Fphotos%2F41100000%2F-Toshiro-Hitsugaya-bleach-anime-41102719-500-281.gif 7 | http://gss0.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/aec379310a55b31905caba3b43a98226cffc1748.jpg 8 | 9 | 10 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/File/localBigImage0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowserDemo/Example/File/localBigImage0.jpeg -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/File/localImage0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowserDemo/Example/File/localImage0.jpg -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/File/localImage1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowserDemo/Example/File/localImage1.gif -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/File/localLongImage0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowserDemo/Example/File/localLongImage0.jpeg -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/File/localVideo0.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indulgeIn/YBImageBrowser/ef2ace7bec42eac5f5e50bd5684dfc67d9a9b294/YBImageBrowserDemo/Example/File/localVideo0.mp4 -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/图片显示预处理(例添加水印)/TestDController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestDController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "BaseListController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface TestDController : BaseListController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/图片显示预处理(例添加水印)/TestDController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestDController.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "TestDController.h" 10 | #import "YBImageBrowser.h" 11 | #import "YBIBUtilities.h" 12 | 13 | @interface TestDController () 14 | 15 | @end 16 | 17 | @implementation TestDController 18 | 19 | #pragma mark - life cycle 20 | 21 | - (instancetype)init { 22 | self = [super init]; 23 | if (self) { 24 | self.dataArray = [BaseFileManager imageURLs]; 25 | } 26 | return self; 27 | } 28 | 29 | + (NSString *)yb_title { 30 | return @"图片显示预处理(例添加水印)"; 31 | } 32 | 33 | #pragma mark - override 34 | 35 | - (void)selectedIndex:(NSInteger)index { 36 | 37 | NSMutableArray *datas = [NSMutableArray array]; 38 | [self.dataArray enumerateObjectsUsingBlock:^(NSString *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 39 | 40 | // 网络图片 41 | YBIBImageData *data = [YBIBImageData new]; 42 | data.imageURL = [NSURL URLWithString:obj]; 43 | data.projectiveView = [self viewAtIndex:idx]; 44 | data.originImageModifier = ^(YBIBImageData *imageData, UIImage * _Nonnull image, void (^ _Nonnull completion)(UIImage * _Nonnull)) { 45 | if ([imageData shouldCompressWithImage:image]) { 46 | completion(image); 47 | NSLog(@"尺寸过大,不处理"); 48 | return; 49 | } 50 | YBIB_DISPATCH_ASYNC(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 51 | // 添加一个水印 52 | UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); 53 | [image drawAtPoint:CGPointZero]; 54 | NSString *logo = @"LOGO"; 55 | NSMutableDictionary *dict = [NSMutableDictionary dictionary]; 56 | dict[NSForegroundColorAttributeName] = [UIColor orangeColor]; 57 | dict[NSFontAttributeName] = [UIFont boldSystemFontOfSize:40]; 58 | [logo drawAtPoint:CGPointMake(10, 10) withAttributes:dict]; 59 | UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 60 | UIGraphicsEndImageContext(); 61 | YBIB_DISPATCH_ASYNC_MAIN(^{ 62 | completion(img); 63 | }) 64 | }) 65 | }; 66 | [datas addObject:data]; 67 | 68 | }]; 69 | 70 | YBImageBrowser *browser = [YBImageBrowser new]; 71 | browser.dataSourceArray = datas; 72 | browser.currentPage = index; 73 | browser.defaultToolViewHandler.topView.operationType = YBIBTopViewOperationTypeSave; 74 | [browser show]; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/展示图片+视频/TestAController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestAController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "BaseListController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface TestAController : BaseListController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/添加到控制器使用(以相册为例)/TestEController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestEController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "BaseListController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface TestEController : BaseListController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/添加到控制器使用(以相册为例)/TestEController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestEController.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "TestEController.h" 10 | #import "TestImageBrowser.h" 11 | #import "YBIBPhotoAlbumManager.h" 12 | 13 | @interface TestEController () 14 | 15 | @end 16 | 17 | @implementation TestEController 18 | 19 | #pragma mark - life cycle 20 | 21 | - (instancetype)init { 22 | self = [super init]; 23 | if (self) { 24 | [YBIBPhotoAlbumManager getPhotoAlbumAuthorizationSuccess:^{ 25 | self.dataArray = [BaseFileManager imagePHAssets]; 26 | } failed:^{}]; 27 | } 28 | return self; 29 | } 30 | 31 | + (NSString *)yb_title { 32 | return @"添加到控制器使用(以相册为例)"; 33 | } 34 | 35 | #pragma mark - override 36 | 37 | - (void)selectedIndex:(NSInteger)index { 38 | 39 | //使用控制器保证的图片浏览器 40 | TestImageBrowser *browser = [TestImageBrowser new]; 41 | browser.imagePHAssets = self.dataArray; 42 | browser.selectIndex = index; 43 | [self.navigationController pushViewController:browser animated:YES]; 44 | 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/添加到控制器使用(以相册为例)/TestImageBrowser.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestImageBrowser.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface TestImageBrowser : UIViewController 15 | 16 | @property (nonatomic, copy) NSArray *imagePHAssets; 17 | 18 | @property (nonatomic, assign) NSInteger selectIndex; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/添加到控制器使用(以相册为例)/TestImageBrowser.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestImageBrowser.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "TestImageBrowser.h" 10 | #import "YBImageBrowser.h" 11 | #import "YBIBVideoData.h" 12 | #import "YBIBUtilities.h" 13 | 14 | @interface TestImageBrowser () 15 | 16 | @end 17 | 18 | @implementation TestImageBrowser 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | self.view.backgroundColor = UIColor.whiteColor; 23 | 24 | /* 25 | 用控制器包装处理起来有些麻烦,需要关闭很多效果 26 | */ 27 | 28 | YBImageBrowser *browser = [YBImageBrowser new]; 29 | // 禁止旋转(但是若当前控制器能旋转,图片浏览器也会跟随,布局可能会错位,这种情况还待处理) 30 | browser.supportedOrientations = UIInterfaceOrientationMaskPortrait; 31 | // 这里演示使用代理来处理数据源(当然用数组也可以) 32 | browser.dataSource = self; 33 | browser.currentPage = self.selectIndex; 34 | // 关闭入场和出场动效 35 | browser.defaultAnimatedTransition.showType = YBIBTransitionTypeNone; 36 | browser.defaultAnimatedTransition.hideType = YBIBTransitionTypeNone; 37 | // 删除工具视图(你可能需要自定义的工具视图,那请自己实现吧) 38 | browser.toolViewHandlers = @[]; 39 | // 由于 self.view 的大小可能会变化,所以需要显式的赋值容器大小 40 | CGSize size = CGSizeMake(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height - YBIBStatusbarHeight() - 44); 41 | [browser showToView:self.view containerSize:size]; 42 | 43 | } 44 | 45 | - (UIInterfaceOrientationMask)supportedInterfaceOrientations { 46 | return UIInterfaceOrientationMaskPortrait; 47 | } 48 | 49 | #pragma mark - 50 | 51 | - (NSInteger)yb_numberOfCellsInImageBrowser:(YBImageBrowser *)imageBrowser { 52 | return self.imagePHAssets.count; 53 | } 54 | 55 | - (id)yb_imageBrowser:(YBImageBrowser *)imageBrowser dataForCellAtIndex:(NSInteger)index { 56 | 57 | PHAsset *asset = (PHAsset *)self.imagePHAssets[index]; 58 | if (asset.mediaType == PHAssetMediaTypeVideo) { 59 | 60 | // 系统相册的视频 61 | YBIBVideoData *data = [YBIBVideoData new]; 62 | data.videoPHAsset = asset; 63 | data.interactionProfile.disable = YES; //关闭手势交互 64 | data.shouldHideForkButton = YES; //隐藏播放时的取消按钮 65 | data.singleTouchBlock = ^(YBIBVideoData * _Nonnull videoData) {}; //拦截单击事件 66 | return data; 67 | 68 | } else if (asset.mediaType == PHAssetMediaTypeImage) { 69 | 70 | // 系统相册的图片 71 | YBIBImageData *data = [YBIBImageData new]; 72 | data.imagePHAsset = asset; 73 | data.interactionProfile.disable = YES; //关闭手势交互 74 | data.singleTouchBlock = ^(YBIBImageData * _Nonnull imageData) {}; //拦截单击事件 75 | return data; 76 | 77 | } 78 | return nil; 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/用代理配置数据源(以相册为例)/TestFController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestFController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/8/4. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "BaseListController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface TestFController : BaseListController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/用代理配置数据源(以相册为例)/TestFController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestFController.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/8/4. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "TestFController.h" 10 | #import "YBIBPhotoAlbumManager.h" 11 | #import "YBImageBrowser.h" 12 | #import "YBIBVideoData.h" 13 | 14 | @interface TestFController () 15 | 16 | @end 17 | 18 | @implementation TestFController 19 | 20 | #pragma mark - life cycle 21 | 22 | - (instancetype)init { 23 | self = [super init]; 24 | if (self) { 25 | [YBIBPhotoAlbumManager getPhotoAlbumAuthorizationSuccess:^{ 26 | self.dataArray = [BaseFileManager imagePHAssets]; 27 | } failed:^{}]; 28 | } 29 | return self; 30 | } 31 | 32 | + (NSString *)yb_title { 33 | return @"用代理配置数据源(以相册为例)"; 34 | } 35 | 36 | #pragma mark - override 37 | 38 | - (void)selectedIndex:(NSInteger)index { 39 | 40 | YBImageBrowser *browser = [YBImageBrowser new]; 41 | browser.dataSource = self; 42 | browser.currentPage = index; 43 | [browser show]; 44 | } 45 | 46 | #pragma mark - 47 | 48 | - (NSInteger)yb_numberOfCellsInImageBrowser:(YBImageBrowser *)imageBrowser { 49 | return self.dataArray.count; 50 | } 51 | 52 | - (id)yb_imageBrowser:(YBImageBrowser *)imageBrowser dataForCellAtIndex:(NSInteger)index { 53 | 54 | PHAsset *asset = (PHAsset *)self.dataArray[index]; 55 | if (asset.mediaType == PHAssetMediaTypeVideo) { 56 | 57 | // 系统相册的视频 58 | YBIBVideoData *data = [YBIBVideoData new]; 59 | data.videoPHAsset = asset; 60 | data.projectiveView = [self viewAtIndex:index]; 61 | return data; 62 | 63 | } else if (asset.mediaType == PHAssetMediaTypeImage) { 64 | 65 | // 系统相册的图片 66 | YBIBImageData *data = [YBIBImageData new]; 67 | data.imagePHAsset = asset; 68 | data.projectiveView = [self viewAtIndex:index]; 69 | return data; 70 | 71 | } 72 | 73 | return nil; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义 Cell/TestCController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestCController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "BaseListController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface TestCController : BaseListController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义 Cell/TestCController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestCController.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "TestCController.h" 10 | #import "YBImageBrowser.h" 11 | #import "TestCustomData.h" 12 | 13 | static NSString *kAdvertKey = @"广告位"; 14 | 15 | @interface TestCController () 16 | 17 | @end 18 | 19 | @implementation TestCController 20 | 21 | #pragma mark - life cycle 22 | 23 | - (instancetype)init { 24 | self = [super init]; 25 | if (self) { 26 | NSMutableArray *array = [NSMutableArray array]; 27 | [array addObjectsFromArray:[BaseFileManager imageURLs]]; 28 | [array addObject:kAdvertKey]; 29 | self.dataArray = array; 30 | } 31 | return self; 32 | } 33 | 34 | + (NSString *)yb_title { 35 | return @"自定义 Cell"; 36 | } 37 | 38 | #pragma mark - 39 | 40 | - (void)yb_imageBrowser:(YBImageBrowser *)imageBrowser pageChanged:(NSInteger)page data:(id)data { 41 | // 当是自定义的 Cell 时,隐藏右边的操作按钮 42 | // 对于工具栏的处理自定义一个 id 是最灵活的方式,默认实现很多时候可能满足不了需求 43 | imageBrowser.defaultToolViewHandler.topView.operationButton.hidden = [data isKindOfClass:TestCustomData.self]; 44 | } 45 | 46 | #pragma mark - override 47 | 48 | - (void)selectedIndex:(NSInteger)index { 49 | 50 | NSMutableArray *datas = [NSMutableArray array]; 51 | [self.dataArray enumerateObjectsUsingBlock:^(NSString *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 52 | if ([obj isEqualToString:kAdvertKey]) { 53 | 54 | // 自定义的广告 Cell 55 | TestCustomData *data = [TestCustomData new]; 56 | data.text = @"这是一个广告"; 57 | [datas addObject:data]; 58 | 59 | } else { 60 | 61 | // 网络图片 62 | YBIBImageData *data = [YBIBImageData new]; 63 | data.imageURL = [NSURL URLWithString:obj]; 64 | data.projectiveView = [self viewAtIndex:idx]; 65 | [datas addObject:data]; 66 | 67 | } 68 | }]; 69 | 70 | YBImageBrowser *browser = [YBImageBrowser new]; 71 | browser.dataSourceArray = datas; 72 | browser.currentPage = index; 73 | browser.delegate = self; 74 | [browser show]; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义 Cell/TestCustomCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestCustomCell.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "YBIBCellProtocol.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface TestCustomCell : UICollectionViewCell 15 | 16 | @end 17 | 18 | NS_ASSUME_NONNULL_END 19 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义 Cell/TestCustomCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestCustomCell.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "TestCustomCell.h" 10 | #import "TestCustomData.h" 11 | 12 | @interface TestCustomCell () 13 | @property (weak, nonatomic) IBOutlet UILabel *contentLabel; 14 | @end 15 | 16 | @implementation TestCustomCell 17 | 18 | - (void)awakeFromNib { 19 | [super awakeFromNib]; 20 | self.contentView.backgroundColor = UIColor.whiteColor; 21 | } 22 | 23 | #pragma mark - 24 | 25 | @synthesize yb_cellData = _yb_cellData; 26 | @synthesize yb_hideBrowser = _yb_hideBrowser; 27 | 28 | - (void)setYb_cellData:(id)yb_cellData { 29 | _yb_cellData = yb_cellData; 30 | 31 | TestCustomData *data = (TestCustomData *)yb_cellData; 32 | self.contentLabel.text = data.text; 33 | } 34 | 35 | #pragma mark - touch 36 | 37 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 38 | [super touchesEnded:touches withEvent:event]; 39 | self.yb_hideBrowser(); 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义 Cell/TestCustomData.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestCustomData.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "YBIBDataProtocol.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface TestCustomData : NSObject 15 | 16 | @property (nonatomic, copy) NSString *text; 17 | 18 | @end 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义 Cell/TestCustomData.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestCustomData.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "TestCustomData.h" 10 | #import "TestCustomCell.h" 11 | 12 | @implementation TestCustomData 13 | 14 | #pragma mark - 15 | 16 | - (Class)yb_classOfCell { 17 | return TestCustomCell.self; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义工具视图(例查看原图)/TestBController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestBController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "BaseListController.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface TestBController : BaseListController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义工具视图(例查看原图)/TestBController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestBController.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "TestBController.h" 10 | #import "YBImageBrowser.h" 11 | #import "TestToolViewHandler.h" 12 | 13 | @interface TestBController () 14 | 15 | @end 16 | 17 | @implementation TestBController 18 | 19 | #pragma mark - life cycle 20 | 21 | - (instancetype)init { 22 | self = [super init]; 23 | if (self) { 24 | self.dataArray = [BaseFileManager imageURLs]; 25 | } 26 | return self; 27 | } 28 | 29 | + (NSString *)yb_title { 30 | return @"自定义工具视图(例查看原图)"; 31 | } 32 | 33 | #pragma mark - override 34 | 35 | - (void)selectedIndex:(NSInteger)index { 36 | 37 | NSMutableArray *datas = [NSMutableArray array]; 38 | [self.dataArray enumerateObjectsUsingBlock:^(NSString *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 39 | 40 | YBIBImageData *data = [YBIBImageData new]; 41 | data.imageURL = [NSURL URLWithString:obj]; 42 | data.projectiveView = [self viewAtIndex:idx]; 43 | // 这里放的是原图地址(实际业务中请按需关联) 44 | data.extraData = [NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1563259169388&di=80094a1dbee952cad67b72b0037eb2fc&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20180313%2F49da94b727b54762947d625ba5f92196.jpeg"]; 45 | [datas addObject:data]; 46 | 47 | }]; 48 | 49 | YBImageBrowser *browser = [YBImageBrowser new]; 50 | // 自定义工具栏 51 | browser.toolViewHandlers = @[TestToolViewHandler.new]; 52 | browser.dataSourceArray = datas; 53 | browser.currentPage = index; 54 | [browser show]; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Example/自定义工具视图(例查看原图)/TestToolViewHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestToolViewHandler.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/16. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "YBIBToolViewHandler.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface TestToolViewHandler : NSObject 15 | 16 | @end 17 | 18 | NS_ASSUME_NONNULL_END 19 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | 图片浏览器 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSApplicationCategoryType 24 | 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | 32 | NSPhotoLibraryAddUsageDescription 33 | 是否允许此App存储图片到你的媒体资料库? 34 | NSPhotoLibraryUsageDescription 35 | 是否允许此App访问你的媒体资料库以存储图片? 36 | UILaunchStoryboardName 37 | LaunchScreen 38 | UIMainStoryboardFile 39 | 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationPortrait 48 | UIInterfaceOrientationPortraitUpsideDown 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | UISupportedInterfaceOrientations~ipad 52 | 53 | UIInterfaceOrientationPortrait 54 | UIInterfaceOrientationPortraitUpsideDown 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | UIViewControllerBasedStatusBarAppearance 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/MainController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MainController : UIViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/MainListController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MainController : UIViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/MainListController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainController.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/7/15. 6 | // Copyright © 2019 杨波. All rights reserved. 7 | // 8 | 9 | #import "MainController.h" 10 | 11 | @interface MainController () 12 | @property (nonatomic, strong) UITableView *tableView; 13 | @end 14 | 15 | @implementation MainController { 16 | NSArray *_controllers; 17 | } 18 | 19 | #pragma mark - life cycle 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | _controllers = @[]; 24 | [self.view addSubview:self.tableView]; 25 | } 26 | 27 | - (void)viewWillLayoutSubviews { 28 | [super viewWillLayoutSubviews]; 29 | self.tableView.frame = self.view.bounds; 30 | } 31 | 32 | #pragma mark - 33 | 34 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 35 | return _controllers.count; 36 | } 37 | 38 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 39 | return 70; 40 | } 41 | 42 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 43 | static NSString * const kCellIdentifier = @"UITableViewCell"; 44 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier]; 45 | if (!cell) { 46 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier]; 47 | cell.textLabel.font = [UIFont boldSystemFontOfSize:18]; 48 | } 49 | cell.textLabel.text = _controllers[indexPath.row].title; 50 | return cell; 51 | } 52 | 53 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 54 | 55 | } 56 | 57 | #pragma mark - getter 58 | 59 | - (UITableView *)tableView { 60 | if (!_tableView) { 61 | _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; 62 | _tableView.delegate = self; 63 | _tableView.dataSource = self; 64 | if (@available(iOS 11.0, *)) { 65 | _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; 66 | } 67 | _tableView.contentInset = UIEdgeInsetsMake(0, 0, 34, 0); 68 | } 69 | return _tableView; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/MainNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainNavigationController.h 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/9/17. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MainNavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/MainNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainNavigationController.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2018/9/17. 6 | // Copyright © 2018年 波儿菜. All rights reserved. 7 | // 8 | 9 | #import "MainNavigationController.h" 10 | 11 | @implementation MainNavigationController 12 | 13 | - (BOOL)shouldAutorotate { 14 | return [self.topViewController shouldAutorotate]; 15 | } 16 | 17 | - (UIInterfaceOrientationMask)supportedInterfaceOrientations { 18 | // return [self.topViewController supportedInterfaceOrientations]; 19 | return UIInterfaceOrientationMaskPortrait; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/PrefixHeader.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PrefixHeader.pch 3 | // ToolsDemoByYangBo 4 | // 5 | // Created by 杨波 on 17/3/3. 6 | // Copyright © 2017年 yangbo. All rights reserved. 7 | // 8 | 9 | #ifndef PrefixHeader_pch 10 | #define PrefixHeader_pch 11 | 12 | #if DEBUG 13 | #define NSLog(FORMAT, ...) fprintf(stderr,"%s\n",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]) 14 | #else 15 | #define NSLog(FORMAT, ...) nil 16 | #endif 17 | 18 | #endif /* PrefixHeader_pch */ 19 | -------------------------------------------------------------------------------- /YBImageBrowserDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // YBImageBrowserDemo 4 | // 5 | // Created by 波儿菜 on 2019/6/5. 6 | // Copyright © 2019 波儿菜. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------