├── KDCycleBannerViewDemo ├── Podfile ├── Pods │ ├── Headers │ │ ├── Build │ │ │ └── SDWebImage │ │ │ │ ├── SDImageCache.h │ │ │ │ ├── UIImage+GIF.h │ │ │ │ ├── SDWebImageCompat.h │ │ │ │ ├── SDWebImageDecoder.h │ │ │ │ ├── SDWebImageManager.h │ │ │ │ ├── UIButton+WebCache.h │ │ │ │ ├── SDWebImageDownloader.h │ │ │ │ ├── SDWebImageOperation.h │ │ │ │ ├── SDWebImagePrefetcher.h │ │ │ │ ├── UIImage+MultiFormat.h │ │ │ │ ├── UIImageView+WebCache.h │ │ │ │ ├── NSData+ImageContentType.h │ │ │ │ ├── UIView+WebCacheOperation.h │ │ │ │ ├── SDWebImageDownloaderOperation.h │ │ │ │ └── UIImageView+HighlightedWebCache.h │ │ └── Public │ │ │ └── SDWebImage │ │ │ ├── SDImageCache.h │ │ │ ├── UIImage+GIF.h │ │ │ ├── SDWebImageCompat.h │ │ │ ├── SDWebImageDecoder.h │ │ │ ├── SDWebImageManager.h │ │ │ ├── UIButton+WebCache.h │ │ │ ├── SDWebImageDownloader.h │ │ │ ├── SDWebImageOperation.h │ │ │ ├── SDWebImagePrefetcher.h │ │ │ ├── UIImage+MultiFormat.h │ │ │ ├── UIImageView+WebCache.h │ │ │ ├── NSData+ImageContentType.h │ │ │ ├── UIView+WebCacheOperation.h │ │ │ ├── SDWebImageDownloaderOperation.h │ │ │ └── UIImageView+HighlightedWebCache.h │ ├── Target Support Files │ │ ├── Pods-SDWebImage │ │ │ ├── Pods-SDWebImage.xcconfig │ │ │ ├── Pods-SDWebImage-prefix.pch │ │ │ ├── Pods-SDWebImage-dummy.m │ │ │ └── Pods-SDWebImage-Private.xcconfig │ │ └── Pods │ │ │ ├── Pods-dummy.m │ │ │ ├── Pods.debug.xcconfig │ │ │ ├── Pods.release.xcconfig │ │ │ ├── Pods-environment.h │ │ │ ├── Pods-acknowledgements.markdown │ │ │ ├── Pods-acknowledgements.plist │ │ │ └── Pods-resources.sh │ ├── Manifest.lock │ ├── SDWebImage │ │ ├── SDWebImage │ │ │ ├── UIImage+MultiFormat.h │ │ │ ├── SDWebImageOperation.h │ │ │ ├── UIImage+GIF.h │ │ │ ├── SDWebImageDecoder.h │ │ │ ├── NSData+ImageContentType.h │ │ │ ├── UIView+WebCacheOperation.h │ │ │ ├── NSData+ImageContentType.m │ │ │ ├── SDWebImageCompat.m │ │ │ ├── SDWebImageCompat.h │ │ │ ├── UIView+WebCacheOperation.m │ │ │ ├── SDWebImageDownloaderOperation.h │ │ │ ├── SDWebImageDecoder.m │ │ │ ├── UIImage+MultiFormat.m │ │ │ ├── SDWebImagePrefetcher.h │ │ │ ├── UIImageView+HighlightedWebCache.m │ │ │ ├── UIImageView+HighlightedWebCache.h │ │ │ ├── UIImage+GIF.m │ │ │ ├── SDWebImagePrefetcher.m │ │ │ ├── SDWebImageDownloader.h │ │ │ ├── SDImageCache.h │ │ │ ├── UIImageView+WebCache.m │ │ │ ├── UIImageView+WebCache.h │ │ │ ├── SDWebImageManager.h │ │ │ ├── SDWebImageDownloader.m │ │ │ ├── UIButton+WebCache.m │ │ │ └── UIButton+WebCache.h │ │ ├── LICENSE │ │ └── README.md │ └── Pods.xcodeproj │ │ └── xcuserdata │ │ └── kingiol.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ ├── Pods.xcscheme │ │ └── Pods-SDWebImage.xcscheme ├── KDCycleBannerViewDemo │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── image1.png │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── KDCycleBannerViewDemo-Prefix.pch │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── KDCycleBannerViewDemo-Info.plist │ ├── Base.lproj │ │ ├── Main_iPad.storyboard │ │ └── Main_iPhone.storyboard │ ├── AppDelegate.m │ └── ViewController.m ├── KDCycleBannerViewDemoTests │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── KDCycleBannerViewDemoTests-Info.plist │ └── KDCycleBannerViewDemoTests.m ├── KDCycleBannerViewDemo.xcworkspace │ ├── xcuserdata │ │ └── kingiol.xcuserdatad │ │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ │ └── UserInterfaceState.xcuserstate │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── KDCycleBannerViewDemo.xccheckout ├── KDCycleBannerViewDemo.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcuserdata │ │ │ └── kingiol.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcshareddata │ │ │ └── KDCycleBannerViewDemo.xccheckout │ └── xcuserdata │ │ └── kingiol.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── KDCycleBannerViewDemo.xcscheme └── Podfile.lock ├── ScreenShoot.gif ├── KDCycleBannerView.podspec ├── .gitignore ├── LICENSE ├── KDCycleBannerView ├── KDCycleBannerView.h └── KDCycleBannerView.m └── README.md /KDCycleBannerViewDemo/Podfile: -------------------------------------------------------------------------------- 1 | inhibit_all_warnings! 2 | 3 | pod 'SDWebImage' -------------------------------------------------------------------------------- /ScreenShoot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingiol/KDCycleBannerView/HEAD/ScreenShoot.gif -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/SDImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDImageCache.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImage+GIF.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/SDImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDImageCache.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImage+GIF.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageCompat.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDecoder.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/SDWebImageManager.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageManager.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/UIButton+WebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIButton+WebCache.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageCompat.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDecoder.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/SDWebImageManager.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageManager.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/UIButton+WebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIButton+WebCache.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemoTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/SDWebImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloader.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageOperation.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/UIImageView+WebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImageView+WebCache.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/SDWebImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloader.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageOperation.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/UIImageView+WebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImageView+WebCache.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/NSData+ImageContentType.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/NSData+ImageContentType.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods-SDWebImage/Pods-SDWebImage.xcconfig: -------------------------------------------------------------------------------- 1 | PODS_SDWEBIMAGE_OTHER_LDFLAGS = -framework "ImageIO" -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Build/SDWebImage/UIImageView+HighlightedWebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Headers/Public/SDWebImage/UIImageView+HighlightedWebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingiol/KDCycleBannerView/HEAD/KDCycleBannerViewDemo/KDCycleBannerViewDemo/image1.png -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods-SDWebImage/Pods-SDWebImage-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-environment.h" 6 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods/Pods-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods : NSObject 3 | @end 4 | @implementation PodsDummy_Pods 5 | @end 6 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcworkspace/xcuserdata/kingiol.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods-SDWebImage/Pods-SDWebImage-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_SDWebImage : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_SDWebImage 5 | @end 6 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcworkspace/xcuserdata/kingiol.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingiol/KDCycleBannerView/HEAD/KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcworkspace/xcuserdata/kingiol.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SDWebImage (3.7.1): 3 | - SDWebImage/Core (= 3.7.1) 4 | - SDWebImage/Core (3.7.1) 5 | 6 | DEPENDENCIES: 7 | - SDWebImage 8 | 9 | SPEC CHECKSUMS: 10 | SDWebImage: 116e88633b5b416ea0ca4b334a4ac59cf72dd38d 11 | 12 | COCOAPODS: 0.35.0 13 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SDWebImage (3.7.1): 3 | - SDWebImage/Core (= 3.7.1) 4 | - SDWebImage/Core (3.7.1) 5 | 6 | DEPENDENCIES: 7 | - SDWebImage 8 | 9 | SPEC CHECKSUMS: 10 | SDWebImage: 116e88633b5b416ea0ca4b334a4ac59cf72dd38d 11 | 12 | COCOAPODS: 0.35.0 13 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcodeproj/project.xcworkspace/xcuserdata/kingiol.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingiol/KDCycleBannerView/HEAD/KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcodeproj/project.xcworkspace/xcuserdata/kingiol.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // KDCycleBannerViewDemo 4 | // 5 | // Created by Kingiol on 14-4-11. 6 | // Copyright (c) 2014年 Kingiol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (MultiFormat) 12 | 13 | + (UIImage *)sd_imageWithData:(NSData *)data; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // KDCycleBannerViewDemo 4 | // 5 | // Created by Kingiol on 14-4-11. 6 | // Copyright (c) 2014年 Kingiol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods-SDWebImage/Pods-SDWebImage-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-SDWebImage.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Build" "${PODS_ROOT}/Headers/Build/SDWebImage" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage" 4 | OTHER_LDFLAGS = ${PODS_SDWEBIMAGE_OTHER_LDFLAGS} -ObjC 5 | PODS_ROOT = ${SRCROOT} -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/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 | @protocol SDWebImageOperation 12 | 13 | - (void)cancel; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // KDCycleBannerViewDemo 4 | // 5 | // Created by Kingiol on 14-4-11. 6 | // Copyright (c) 2014年 Kingiol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods/Pods.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage" 4 | OTHER_LDFLAGS = -ObjC -l"Pods-SDWebImage" -framework "ImageIO" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods/Pods.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage" 4 | OTHER_LDFLAGS = -ObjC -l"Pods-SDWebImage" -framework "ImageIO" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/KDCycleBannerViewDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.h 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (GIF) 12 | 13 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name; 14 | 15 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data; 16 | 17 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import 12 | #import "SDWebImageCompat.h" 13 | 14 | @interface UIImage (ForceDecode) 15 | 16 | + (UIImage *)decodedImageWithImage:(UIImage *)image; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /KDCycleBannerView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'KDCycleBannerView' 3 | s.version = '1.1.1' 4 | s.license = 'MIT' 5 | s.homepage = 'https://github.com/kingiol/KDCycleBannerView' 6 | s.authors = { 'Kingiol' => 'kingxiaokang@gmail.com' } 7 | s.summary = 'A Cycle Or Loop ScrollView For Banner' 8 | 9 | # Source Info 10 | s.ios.deployment_target = '6.0' 11 | s.source = { :git => 'https://github.com/kingiol/KDCycleBannerView.git', :tag => '1.1.1' } 12 | s.source_files = 'KDCycleBannerView/*{h,m}' 13 | 14 | s.requires_arc = true 15 | 16 | s.public_header_files = 'KDCycleBannerView/*.h' 17 | 18 | # Pod Dependencies 19 | s.dependency 'SDWebImage' 20 | 21 | end -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import 7 | 8 | @interface NSData (ImageContentType) 9 | 10 | /** 11 | * Compute the content type for an image data 12 | * 13 | * @param data the input data 14 | * 15 | * @return the content type as string (i.e. image/jpeg, image/gif) 16 | */ 17 | + (NSString *)sd_contentTypeForImageData:(NSData *)data; 18 | 19 | @end 20 | 21 | 22 | @interface NSData (ImageContentTypeDeprecated) 23 | 24 | + (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 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 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | 33 | Carthage/Build 34 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods/Pods-environment.h: -------------------------------------------------------------------------------- 1 | 2 | // To check if a library is compiled with CocoaPods you 3 | // can use the `COCOAPODS` macro definition which is 4 | // defined in the xcconfigs so it is available in 5 | // headers also when they are imported in the client 6 | // project. 7 | 8 | 9 | // SDWebImage 10 | #define COCOAPODS_POD_AVAILABLE_SDWebImage 11 | #define COCOAPODS_VERSION_MAJOR_SDWebImage 3 12 | #define COCOAPODS_VERSION_MINOR_SDWebImage 7 13 | #define COCOAPODS_VERSION_PATCH_SDWebImage 1 14 | 15 | // SDWebImage/Core 16 | #define COCOAPODS_POD_AVAILABLE_SDWebImage_Core 17 | #define COCOAPODS_VERSION_MAJOR_SDWebImage_Core 3 18 | #define COCOAPODS_VERSION_MINOR_SDWebImage_Core 7 19 | #define COCOAPODS_VERSION_PATCH_SDWebImage_Core 1 20 | 21 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcodeproj/xcuserdata/kingiol.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | KDCycleBannerViewDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 62EFD89F18F7DA09001A1D42 16 | 17 | primary 18 | 19 | 20 | 62EFD8C318F7DA0A001A1D42 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemoTests/KDCycleBannerViewDemoTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.kingiol.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Pods.xcodeproj/xcuserdata/kingiol.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-SDWebImage.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 3E12C27C247FA85BF5FFB7F3 21 | 22 | primary 23 | 24 | 25 | E0E566795902AB4FC645F325 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemoTests/KDCycleBannerViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // KDCycleBannerViewDemoTests.m 3 | // KDCycleBannerViewDemoTests 4 | // 5 | // Created by Kingiol on 14-4-11. 6 | // Copyright (c) 2014年 Kingiol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KDCycleBannerViewDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation KDCycleBannerViewDemoTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Kingiol 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. -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/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 10 | #import "SDWebImageManager.h" 11 | 12 | @interface UIView (WebCacheOperation) 13 | 14 | /** 15 | * Set the image load operation (storage in a UIView based dictionary) 16 | * 17 | * @param operation the operation 18 | * @param key key for storing the operation 19 | */ 20 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; 21 | 22 | /** 23 | * Cancel all operations for the current UIView and key 24 | * 25 | * @param key key for identifying the operations 26 | */ 27 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; 28 | 29 | /** 30 | * Just remove the operations corresponding to the current UIView and key without cancelling them 31 | * 32 | * @param key key for identifying the operations 33 | */ 34 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Olivier Poitrey 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 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## SDWebImage 5 | 6 | Copyright (c) 2009 Olivier Poitrey 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 | Generated by CocoaPods - http://cocoapods.org 28 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import "NSData+ImageContentType.h" 7 | 8 | 9 | @implementation NSData (ImageContentType) 10 | 11 | + (NSString *)sd_contentTypeForImageData:(NSData *)data { 12 | uint8_t c; 13 | [data getBytes:&c length:1]; 14 | switch (c) { 15 | case 0xFF: 16 | return @"image/jpeg"; 17 | case 0x89: 18 | return @"image/png"; 19 | case 0x47: 20 | return @"image/gif"; 21 | case 0x49: 22 | case 0x4D: 23 | return @"image/tiff"; 24 | case 0x52: 25 | // R as RIFF for WEBP 26 | if ([data length] < 12) { 27 | return nil; 28 | } 29 | 30 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; 31 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { 32 | return @"image/webp"; 33 | } 34 | 35 | return nil; 36 | } 37 | return nil; 38 | } 39 | 40 | @end 41 | 42 | 43 | @implementation NSData (ImageContentTypeDeprecated) 44 | 45 | + (NSString *)contentTypeForImageData:(NSData *)data { 46 | return [self sd_contentTypeForImageData:data]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDWebImageCompat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 11/12/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 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 | inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { 16 | if (!image) { 17 | return nil; 18 | } 19 | 20 | if ([image.images count] > 0) { 21 | NSMutableArray *scaledImages = [NSMutableArray array]; 22 | 23 | for (UIImage *tempImage in image.images) { 24 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; 25 | } 26 | 27 | return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; 28 | } 29 | else { 30 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 31 | CGFloat scale = 1.0; 32 | if (key.length >= 8) { 33 | // Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext) 34 | NSRange range = [key rangeOfString:@"@2x." options:0 range:NSMakeRange(key.length - 8, 5)]; 35 | if (range.location != NSNotFound) { 36 | scale = 2.0; 37 | } 38 | } 39 | 40 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; 41 | image = scaledImage; 42 | } 43 | return image; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /KDCycleBannerView/KDCycleBannerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KDCycleBannerView.h 3 | // KDCycleBannerViewDemo 4 | // 5 | // Created by Kingiol on 14-4-11. 6 | // Copyright (c) 2014年 Kingiol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class KDCycleBannerView; 12 | 13 | typedef void(^CompleteBlock)(void); 14 | 15 | @protocol KDCycleBannerViewDataSource 16 | 17 | @required 18 | - (NSArray *)numberOfKDCycleBannerView:(KDCycleBannerView *)bannerView; 19 | - (UIViewContentMode)contentModeForImageIndex:(NSUInteger)index; 20 | 21 | @optional 22 | - (UIImage *)placeHolderImageOfZeroBannerView; 23 | - (UIImage *)placeHolderImageOfBannerView:(KDCycleBannerView *)bannerView atIndex:(NSUInteger)index; 24 | 25 | @end 26 | 27 | @protocol KDCycleBannerViewDelegate 28 | 29 | @optional 30 | - (void)cycleBannerView:(KDCycleBannerView *)bannerView didScrollToIndex:(NSUInteger)index; 31 | - (void)cycleBannerView:(KDCycleBannerView *)bannerView didSelectedAtIndex:(NSUInteger)index; 32 | 33 | @end 34 | 35 | @interface KDCycleBannerView : UIView 36 | 37 | // Delegate and Datasource 38 | @property (weak, nonatomic) IBOutlet id datasource; 39 | @property (weak, nonatomic) IBOutlet id delegate; 40 | 41 | @property (assign, nonatomic, getter = isContinuous) BOOL continuous; // if YES, then bannerview will show like a carousel, default is NO 42 | @property (assign, nonatomic) NSUInteger autoPlayTimeInterval; // if autoPlayTimeInterval more than 0, the bannerView will autoplay with autoPlayTimeInterval value space, default is 0 43 | 44 | - (void)reloadDataWithCompleteBlock:(CompleteBlock)competeBlock; 45 | - (void)setCurrentPage:(NSInteger)currentPage animated:(BOOL)animated; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcworkspace/xcshareddata/KDCycleBannerViewDemo.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 750D8D07-7F3A-4FFA-AC52-A7878EC2A069 9 | IDESourceControlProjectName 10 | KDCycleBannerViewDemo 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 9417EDBB76A2CE5EA0A29B2B52050085B70FC388 14 | https://github.com/kingiol/KDCycleBannerView.git 15 | 16 | IDESourceControlProjectPath 17 | KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 9417EDBB76A2CE5EA0A29B2B52050085B70FC388 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/kingiol/KDCycleBannerView.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 9417EDBB76A2CE5EA0A29B2B52050085B70FC388 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 9417EDBB76A2CE5EA0A29B2B52050085B70FC388 36 | IDESourceControlWCCName 37 | KDCycleBannerView 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcodeproj/project.xcworkspace/xcshareddata/KDCycleBannerViewDemo.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 3FCFF7AB-2604-4223-8617-7DF59EB066AB 9 | IDESourceControlProjectName 10 | KDCycleBannerViewDemo 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | BFDF68FE-27C9-4A07-BBA4-2196EBD5A815 14 | https://github.com/kingiol/KDCycleBannerView.git 15 | 16 | IDESourceControlProjectPath 17 | KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | BFDF68FE-27C9-4A07-BBA4-2196EBD5A815 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/kingiol/KDCycleBannerView.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | BFDF68FE-27C9-4A07-BBA4-2196EBD5A815 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | BFDF68FE-27C9-4A07-BBA4-2196EBD5A815 36 | IDESourceControlWCCName 37 | KDCycleBannerView 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/KDCycleBannerViewDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.kingiol.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main_iPhone 29 | UIMainStoryboardFile~ipad 30 | Main_iPad 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/Base.lproj/Main_iPad.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 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/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 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 17 | #error SDWebImage doesn't support Deployement Target version < 5.0 18 | #endif 19 | 20 | #if !TARGET_OS_IPHONE 21 | #import 22 | #ifndef UIImage 23 | #define UIImage NSImage 24 | #endif 25 | #ifndef UIImageView 26 | #define UIImageView NSImageView 27 | #endif 28 | #else 29 | 30 | #import 31 | 32 | #endif 33 | 34 | #ifndef NS_ENUM 35 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 36 | #endif 37 | 38 | #ifndef NS_OPTIONS 39 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 40 | #endif 41 | 42 | #if OS_OBJECT_USE_OBJC 43 | #undef SDDispatchQueueRelease 44 | #undef SDDispatchQueueSetterSementics 45 | #define SDDispatchQueueRelease(q) 46 | #define SDDispatchQueueSetterSementics strong 47 | #else 48 | #undef SDDispatchQueueRelease 49 | #undef SDDispatchQueueSetterSementics 50 | #define SDDispatchQueueRelease(q) (dispatch_release(q)) 51 | #define SDDispatchQueueSetterSementics assign 52 | #endif 53 | 54 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); 55 | 56 | typedef void(^SDWebImageNoParamsBlock)(); 57 | 58 | #define dispatch_main_sync_safe(block)\ 59 | if ([NSThread isMainThread]) {\ 60 | block();\ 61 | } else {\ 62 | dispatch_sync(dispatch_get_main_queue(), block);\ 63 | } 64 | 65 | #define dispatch_main_async_safe(block)\ 66 | if ([NSThread isMainThread]) {\ 67 | block();\ 68 | } else {\ 69 | dispatch_async(dispatch_get_main_queue(), block);\ 70 | } 71 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.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 "UIView+WebCacheOperation.h" 10 | #import "objc/runtime.h" 11 | 12 | static char loadOperationKey; 13 | 14 | @implementation UIView (WebCacheOperation) 15 | 16 | - (NSMutableDictionary *)operationDictionary { 17 | NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); 18 | if (operations) { 19 | return operations; 20 | } 21 | operations = [NSMutableDictionary dictionary]; 22 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 23 | return operations; 24 | } 25 | 26 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { 27 | [self sd_cancelImageLoadOperationWithKey:key]; 28 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 29 | [operationDictionary setObject:operation forKey:key]; 30 | } 31 | 32 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { 33 | // Cancel in progress downloader from queue 34 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 35 | id operations = [operationDictionary objectForKey:key]; 36 | if (operations) { 37 | if ([operations isKindOfClass:[NSArray class]]) { 38 | for (id operation in operations) { 39 | if (operation) { 40 | [operation cancel]; 41 | } 42 | } 43 | } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ 44 | [(id) operations cancel]; 45 | } 46 | [operationDictionary removeObjectForKey:key]; 47 | } 48 | } 49 | 50 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key { 51 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 52 | [operationDictionary removeObjectForKey:key]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // KDCycleBannerViewDemo 4 | // 5 | // Created by Kingiol on 14-4-11. 6 | // Copyright (c) 2014年 Kingiol. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // 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. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // 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. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Pods.xcodeproj/xcuserdata/kingiol.xcuserdatad/xcschemes/Pods.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods/Pods-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2009 Olivier Poitrey <rs@dailymotion.com> 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is furnished 24 | to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in all 27 | copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | 38 | Title 39 | SDWebImage 40 | Type 41 | PSGroupSpecifier 42 | 43 | 44 | FooterText 45 | Generated by CocoaPods - http://cocoapods.org 46 | Title 47 | 48 | Type 49 | PSGroupSpecifier 50 | 51 | 52 | StringsTable 53 | Acknowledgements 54 | Title 55 | Acknowledgements 56 | 57 | 58 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Pods.xcodeproj/xcuserdata/kingiol.xcuserdatad/xcschemes/Pods-SDWebImage.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | KDCycleBannerView 2 | ================= 3 | 4 | [![Pod Version](http://img.shields.io/cocoapods/v/KDCycleBannerView.svg)](http://blog.kingiol.com) 5 | [![Pod Version](http://img.shields.io/cocoapods/p/KDCycleBannerView.svg)](http://blog.kingiol.com) 6 | [![License](http://img.shields.io/cocoapods/l/KDCycleBannerView.svg)](http://blog.kingiol.com) 7 | 8 | 9 | A Cycle Or Loop ScrollView For Banner 10 | 11 | ![ScreenShoot](https://github.com/kingiol/KDCycleBannerView/raw/master/ScreenShoot.gif) 12 | 13 | ## Installation with CocoaPods 14 | 15 | [CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries. 16 | 17 | ### Podfile 18 | 19 | ``` ruby 20 | platform :ios 21 | pod "KDCycleBannerView" 22 | ``` 23 | 24 | ## Usage 25 | 26 | It is quite easy to use, you can use this by two methods, one is for code, another is for IB. 27 | 28 | ``` objc 29 | _cycleBannerViewBottom = [KDCycleBannerView new]; 30 | _cycleBannerViewBottom.frame = CGRectMake(20, 270, 280, 150); 31 | _cycleBannerViewBottom.datasource = self; 32 | _cycleBannerViewBottom.delegate = self; 33 | _cycleBannerViewBottom.continuous = YES; 34 | _cycleBannerViewBottom.autoPlayTimeInterval = 5; 35 | [self.view addSubview:_cycleBannerViewBottom]; 36 | ``` 37 | 38 | For more infomation, please check the demo project, Good Luck! 39 | 40 | 41 | ## Inspiration 42 | 43 | 1.[KIImagePager](https://github.com/kimar/KIImagePager) 44 | 45 | 2.[SGFocusImageFrame](https://github.com/shanegao/SGFocusImageFrame) 46 | 47 | ## License 48 | 49 | MIT LICENSE 50 | 51 | Copyright (C) 52 | 53 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 54 | 55 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.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 "SDWebImageDownloader.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | @interface SDWebImageDownloaderOperation : NSOperation 14 | 15 | /** 16 | * The request used by the operation's connection. 17 | */ 18 | @property (strong, nonatomic, readonly) NSURLRequest *request; 19 | 20 | /** 21 | * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. 22 | * 23 | * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. 24 | */ 25 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage; 26 | 27 | /** 28 | * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. 29 | * 30 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. 31 | */ 32 | @property (nonatomic, strong) NSURLCredential *credential; 33 | 34 | /** 35 | * The SDWebImageDownloaderOptions for the receiver. 36 | */ 37 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; 38 | 39 | /** 40 | * Initializes a `SDWebImageDownloaderOperation` object 41 | * 42 | * @see SDWebImageDownloaderOperation 43 | * 44 | * @param request the URL request 45 | * @param options downloader options 46 | * @param progressBlock the block executed when a new chunk of data arrives. 47 | * @note the progress block is executed on a background queue 48 | * @param completedBlock the block executed when the download is done. 49 | * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue 50 | * @param cancelBlock the block executed if the download (operation) is cancelled 51 | * 52 | * @return the initialized instance 53 | */ 54 | - (id)initWithRequest:(NSURLRequest *)request 55 | options:(SDWebImageDownloaderOptions)options 56 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 57 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock 58 | cancelled:(SDWebImageNoParamsBlock)cancelBlock; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import "SDWebImageDecoder.h" 12 | 13 | @implementation UIImage (ForceDecode) 14 | 15 | + (UIImage *)decodedImageWithImage:(UIImage *)image { 16 | if (image.images) { 17 | // Do not decode animated images 18 | return image; 19 | } 20 | 21 | CGImageRef imageRef = image.CGImage; 22 | CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); 23 | CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize}; 24 | 25 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 26 | CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); 27 | 28 | int infoMask = (bitmapInfo & kCGBitmapAlphaInfoMask); 29 | BOOL anyNonAlpha = (infoMask == kCGImageAlphaNone || 30 | infoMask == kCGImageAlphaNoneSkipFirst || 31 | infoMask == kCGImageAlphaNoneSkipLast); 32 | 33 | // CGBitmapContextCreate doesn't support kCGImageAlphaNone with RGB. 34 | // https://developer.apple.com/library/mac/#qa/qa1037/_index.html 35 | if (infoMask == kCGImageAlphaNone && CGColorSpaceGetNumberOfComponents(colorSpace) > 1) { 36 | // Unset the old alpha info. 37 | bitmapInfo &= ~kCGBitmapAlphaInfoMask; 38 | 39 | // Set noneSkipFirst. 40 | bitmapInfo |= kCGImageAlphaNoneSkipFirst; 41 | } 42 | // Some PNGs tell us they have alpha but only 3 components. Odd. 43 | else if (!anyNonAlpha && CGColorSpaceGetNumberOfComponents(colorSpace) == 3) { 44 | // Unset the old alpha info. 45 | bitmapInfo &= ~kCGBitmapAlphaInfoMask; 46 | bitmapInfo |= kCGImageAlphaPremultipliedFirst; 47 | } 48 | 49 | // It calculates the bytes-per-row based on the bitsPerComponent and width arguments. 50 | CGContextRef context = CGBitmapContextCreate(NULL, 51 | imageSize.width, 52 | imageSize.height, 53 | CGImageGetBitsPerComponent(imageRef), 54 | 0, 55 | colorSpace, 56 | bitmapInfo); 57 | CGColorSpaceRelease(colorSpace); 58 | 59 | // If failed, return undecompressed image 60 | if (!context) return image; 61 | 62 | CGContextDrawImage(context, imageRect, imageRef); 63 | CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context); 64 | 65 | CGContextRelease(context); 66 | 67 | UIImage *decompressedImage = [UIImage imageWithCGImage:decompressedImageRef scale:image.scale orientation:image.imageOrientation]; 68 | CGImageRelease(decompressedImageRef); 69 | return decompressedImage; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // KDCycleBannerViewDemo 4 | // 5 | // Created by Kingiol on 14-4-11. 6 | // Copyright (c) 2014年 Kingiol. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | #import "KDCycleBannerView.h" 12 | 13 | @interface ViewController () 14 | 15 | @property (weak, nonatomic) IBOutlet KDCycleBannerView *cycleBannerViewTop; 16 | @property (strong, nonatomic) KDCycleBannerView *cycleBannerViewBottom; 17 | 18 | @property (weak, nonatomic) IBOutlet UITextField *textField; 19 | 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | - (void)viewDidLoad 25 | { 26 | [super viewDidLoad]; 27 | // Do any additional setup after loading the view, typically from a nib. 28 | 29 | _cycleBannerViewTop.autoPlayTimeInterval = 5; 30 | 31 | _cycleBannerViewBottom = [KDCycleBannerView new]; 32 | _cycleBannerViewBottom.frame = CGRectMake(20, 270, 280, 150); 33 | _cycleBannerViewBottom.datasource = self; 34 | _cycleBannerViewBottom.delegate = self; 35 | _cycleBannerViewBottom.continuous = YES; 36 | _cycleBannerViewBottom.autoPlayTimeInterval = 5; 37 | [self.view addSubview:_cycleBannerViewBottom]; 38 | } 39 | 40 | - (void)didReceiveMemoryWarning 41 | { 42 | [super didReceiveMemoryWarning]; 43 | // Dispose of any resources that can be recreated. 44 | } 45 | 46 | #pragma mark - KDCycleBannerViewDataSource 47 | 48 | - (NSArray *)numberOfKDCycleBannerView:(KDCycleBannerView *)bannerView { 49 | 50 | return @[[UIImage imageNamed:@"image1"], 51 | @"http://d.hiphotos.baidu.com/image/w%3D2048/sign=ed59838948ed2e73fce9812cb339a08b/58ee3d6d55fbb2fb9835341f4d4a20a44623dca5.jpg", 52 | @"http://d.hiphotos.baidu.com/image/w%3D2048/sign=5ad7fab780025aafd33279cbcfd5aa64/8601a18b87d6277f15eb8e4f2a381f30e824fcc8.jpg", 53 | @"http://e.hiphotos.baidu.com/image/w%3D2048/sign=df5d0b61cdfc1e17fdbf8b317ea8f703/0bd162d9f2d3572c8d2b20ab8813632763d0c3f8.jpg", 54 | @"http://d.hiphotos.baidu.com/image/w%3D2048/sign=a11d7b94552c11dfded1b823571f63d0/eaf81a4c510fd9f914eee91e272dd42a2934a4c8.jpg"]; 55 | } 56 | 57 | - (UIViewContentMode)contentModeForImageIndex:(NSUInteger)index { 58 | return UIViewContentModeScaleAspectFill; 59 | } 60 | 61 | - (UIImage *)placeHolderImageOfZeroBannerView { 62 | return [UIImage imageNamed:@"image1"]; 63 | } 64 | 65 | #pragma mark - KDCycleBannerViewDelegate 66 | 67 | - (void)cycleBannerView:(KDCycleBannerView *)bannerView didScrollToIndex:(NSUInteger)index { 68 | NSLog(@"didScrollToIndex:%ld", (long)index); 69 | } 70 | 71 | - (void)cycleBannerView:(KDCycleBannerView *)bannerView didSelectedAtIndex:(NSUInteger)index { 72 | NSLog(@"didSelectedAtIndex:%ld", (long)index); 73 | } 74 | 75 | #pragma mark - UITextFieldDelegate 76 | 77 | - (BOOL)textFieldShouldReturn:(UITextField *)textField { 78 | 79 | NSString *text = textField.text; 80 | 81 | @try { 82 | NSInteger page = [text integerValue]; 83 | [_cycleBannerViewTop setCurrentPage:page animated:YES]; 84 | [_cycleBannerViewBottom setCurrentPage:page animated:YES]; 85 | } 86 | @catch (NSException *exception) { 87 | 88 | } 89 | 90 | return YES; 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "UIImage+MultiFormat.h" 10 | #import "UIImage+GIF.h" 11 | #import "NSData+ImageContentType.h" 12 | #import 13 | 14 | #ifdef SD_WEBP 15 | #import "UIImage+WebP.h" 16 | #endif 17 | 18 | @implementation UIImage (MultiFormat) 19 | 20 | + (UIImage *)sd_imageWithData:(NSData *)data { 21 | UIImage *image; 22 | NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; 23 | if ([imageContentType isEqualToString:@"image/gif"]) { 24 | image = [UIImage sd_animatedGIFWithData:data]; 25 | } 26 | #ifdef SD_WEBP 27 | else if ([imageContentType isEqualToString:@"image/webp"]) 28 | { 29 | image = [UIImage sd_imageWithWebPData:data]; 30 | } 31 | #endif 32 | else { 33 | image = [[UIImage alloc] initWithData:data]; 34 | UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; 35 | if (orientation != UIImageOrientationUp) { 36 | image = [UIImage imageWithCGImage:image.CGImage 37 | scale:image.scale 38 | orientation:orientation]; 39 | } 40 | } 41 | 42 | 43 | return image; 44 | } 45 | 46 | 47 | +(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData { 48 | UIImageOrientation result = UIImageOrientationUp; 49 | CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); 50 | if (imageSource) { 51 | CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); 52 | if (properties) { 53 | CFTypeRef val; 54 | int exifOrientation; 55 | val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); 56 | if (val) { 57 | CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); 58 | result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; 59 | } // else - if it's not set it remains at up 60 | CFRelease((CFTypeRef) properties); 61 | } else { 62 | //NSLog(@"NO PROPERTIES, FAIL"); 63 | } 64 | CFRelease(imageSource); 65 | } 66 | return result; 67 | } 68 | 69 | #pragma mark EXIF orientation tag converter 70 | // Convert an EXIF image orientation to an iOS one. 71 | // reference see here: http://sylvana.net/jpegcrop/exif_orientation.html 72 | + (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { 73 | UIImageOrientation orientation = UIImageOrientationUp; 74 | switch (exifOrientation) { 75 | case 1: 76 | orientation = UIImageOrientationUp; 77 | break; 78 | 79 | case 3: 80 | orientation = UIImageOrientationDown; 81 | break; 82 | 83 | case 8: 84 | orientation = UIImageOrientationLeft; 85 | break; 86 | 87 | case 6: 88 | orientation = UIImageOrientationRight; 89 | break; 90 | 91 | case 2: 92 | orientation = UIImageOrientationUpMirrored; 93 | break; 94 | 95 | case 4: 96 | orientation = UIImageOrientationDownMirrored; 97 | break; 98 | 99 | case 5: 100 | orientation = UIImageOrientationLeftMirrored; 101 | break; 102 | 103 | case 7: 104 | orientation = UIImageOrientationRightMirrored; 105 | break; 106 | default: 107 | break; 108 | } 109 | return orientation; 110 | } 111 | 112 | 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.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 "SDWebImageManager.h" 11 | 12 | @class SDWebImagePrefetcher; 13 | 14 | @protocol SDWebImagePrefetcherDelegate 15 | 16 | @optional 17 | 18 | /** 19 | * Called when an image was prefetched. 20 | * 21 | * @param imagePrefetcher The current image prefetcher 22 | * @param imageURL The image url that was prefetched 23 | * @param finishedCount The total number of images that were prefetched (successful or not) 24 | * @param totalCount The total number of images that were to be prefetched 25 | */ 26 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; 27 | 28 | /** 29 | * Called when all images are prefetched. 30 | * @param imagePrefetcher The current image prefetcher 31 | * @param totalCount The total number of images that were prefetched (whether successful or not) 32 | * @param skippedCount The total number of images that were skipped 33 | */ 34 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; 35 | 36 | @end 37 | 38 | typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls); 39 | typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls); 40 | 41 | /** 42 | * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. 43 | */ 44 | @interface SDWebImagePrefetcher : NSObject 45 | 46 | /** 47 | * The web image manager 48 | */ 49 | @property (strong, nonatomic, readonly) SDWebImageManager *manager; 50 | 51 | /** 52 | * Maximum number of URLs to prefetch at the same time. Defaults to 3. 53 | */ 54 | @property (nonatomic, assign) NSUInteger maxConcurrentDownloads; 55 | 56 | /** 57 | * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. 58 | */ 59 | @property (nonatomic, assign) SDWebImageOptions options; 60 | 61 | @property (weak, nonatomic) id delegate; 62 | 63 | /** 64 | * Return the global image prefetcher instance. 65 | */ 66 | + (SDWebImagePrefetcher *)sharedImagePrefetcher; 67 | 68 | /** 69 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 70 | * currently one image is downloaded at a time, 71 | * and skips images for failed downloads and proceed to the next image in the list 72 | * 73 | * @param urls list of URLs to prefetch 74 | */ 75 | - (void)prefetchURLs:(NSArray *)urls; 76 | 77 | /** 78 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 79 | * currently one image is downloaded at a time, 80 | * and skips images for failed downloads and proceed to the next image in the list 81 | * 82 | * @param urls list of URLs to prefetch 83 | * @param progressBlock block to be called when progress updates; 84 | * first parameter is the number of completed (successful or not) requests, 85 | * second parameter is the total number of images originally requested to be prefetched 86 | * @param completionBlock block to be called when prefetching is completed 87 | * first param is the number of completed (successful or not) requests, 88 | * second parameter is the number of skipped requests 89 | */ 90 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock; 91 | 92 | /** 93 | * Remove and cancel queued list 94 | */ 95 | - (void)cancelPrefetching; 96 | 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo/Base.lproj/Main_iPhone.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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/KDCycleBannerViewDemo.xcodeproj/xcuserdata/kingiol.xcuserdatad/xcschemes/KDCycleBannerViewDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/Target Support Files/Pods/Pods-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | install_resource() 10 | { 11 | case $1 in 12 | *.storyboard) 13 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 14 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 15 | ;; 16 | *.xib) 17 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 18 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 19 | ;; 20 | *.framework) 21 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 22 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 23 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 25 | ;; 26 | *.xcdatamodel) 27 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 28 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 29 | ;; 30 | *.xcdatamodeld) 31 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 32 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 33 | ;; 34 | *.xcmappingmodel) 35 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 36 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 37 | ;; 38 | *.xcassets) 39 | ;; 40 | /*) 41 | echo "$1" 42 | echo "$1" >> "$RESOURCES_TO_COPY" 43 | ;; 44 | *) 45 | echo "${PODS_ROOT}/$1" 46 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 47 | ;; 48 | esac 49 | } 50 | 51 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 52 | if [[ "${ACTION}" == "install" ]]; then 53 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 54 | fi 55 | rm -f "$RESOURCES_TO_COPY" 56 | 57 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ] 58 | then 59 | case "${TARGETED_DEVICE_FAMILY}" in 60 | 1,2) 61 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 62 | ;; 63 | 1) 64 | TARGET_DEVICE_ARGS="--target-device iphone" 65 | ;; 66 | 2) 67 | TARGET_DEVICE_ARGS="--target-device ipad" 68 | ;; 69 | *) 70 | TARGET_DEVICE_ARGS="--target-device mac" 71 | ;; 72 | esac 73 | find "${PWD}" -name "*.xcassets" -print0 | xargs -0 actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 74 | fi 75 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.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 "UIImageView+HighlightedWebCache.h" 10 | #import "UIView+WebCacheOperation.h" 11 | 12 | #define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage" 13 | 14 | @implementation UIImageView (HighlightedWebCache) 15 | 16 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url { 17 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 18 | } 19 | 20 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 21 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 22 | } 23 | 24 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { 25 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; 26 | } 27 | 28 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 29 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; 30 | } 31 | 32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { 33 | [self sd_cancelCurrentHighlightedImageLoad]; 34 | 35 | if (url) { 36 | __weak UIImageView *wself = self; 37 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 38 | if (!wself) return; 39 | dispatch_main_sync_safe (^ 40 | { 41 | if (!wself) return; 42 | if (image) { 43 | wself.highlightedImage = image; 44 | [wself setNeedsLayout]; 45 | } 46 | if (completedBlock && finished) { 47 | completedBlock(image, error, cacheType, url); 48 | } 49 | }); 50 | }]; 51 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; 52 | } else { 53 | dispatch_main_async_safe(^{ 54 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 55 | if (completedBlock) { 56 | completedBlock(nil, error, SDImageCacheTypeNone, url); 57 | } 58 | }); 59 | } 60 | } 61 | 62 | - (void)sd_cancelCurrentHighlightedImageLoad { 63 | [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; 64 | } 65 | 66 | @end 67 | 68 | 69 | @implementation UIImageView (HighlightedWebCacheDeprecated) 70 | 71 | - (void)setHighlightedImageWithURL:(NSURL *)url { 72 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 73 | } 74 | 75 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 76 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 77 | } 78 | 79 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { 80 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 81 | if (completedBlock) { 82 | completedBlock(image, error, cacheType); 83 | } 84 | }]; 85 | } 86 | 87 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 88 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 89 | if (completedBlock) { 90 | completedBlock(image, error, cacheType); 91 | } 92 | }]; 93 | } 94 | 95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { 96 | [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 97 | if (completedBlock) { 98 | completedBlock(image, error, cacheType); 99 | } 100 | }]; 101 | } 102 | 103 | - (void)cancelCurrentHighlightedImageLoad { 104 | [self sd_cancelCurrentHighlightedImageLoad]; 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.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 "SDWebImageManager.h" 12 | 13 | /** 14 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. 15 | */ 16 | @interface UIImageView (HighlightedWebCache) 17 | 18 | /** 19 | * Set the imageView `highlightedImage` with an `url`. 20 | * 21 | * The download is asynchronous and cached. 22 | * 23 | * @param url The url for the image. 24 | */ 25 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url; 26 | 27 | /** 28 | * Set the imageView `highlightedImage` with an `url` and custom options. 29 | * 30 | * The download is asynchronous and cached. 31 | * 32 | * @param url The url for the image. 33 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 34 | */ 35 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options; 36 | 37 | /** 38 | * Set the imageView `highlightedImage` with an `url`. 39 | * 40 | * The download is asynchronous and cached. 41 | * 42 | * @param url The url for the image. 43 | * @param completedBlock A block called when operation has been completed. This block has no return value 44 | * and takes the requested UIImage as first parameter. In case of error the image parameter 45 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 46 | * indicating if the image was retrived from the local cache of from the network. 47 | * The forth parameter is the original image url. 48 | */ 49 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 50 | 51 | /** 52 | * Set the imageView `highlightedImage` with an `url` and custom options. 53 | * 54 | * The download is asynchronous and cached. 55 | * 56 | * @param url The url for the image. 57 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 58 | * @param completedBlock A block called when operation has been completed. This block has no return value 59 | * and takes the requested UIImage as first parameter. In case of error the image parameter 60 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 61 | * indicating if the image was retrived from the local cache of from the network. 62 | * The forth parameter is the original image url. 63 | */ 64 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 65 | 66 | /** 67 | * Set the imageView `highlightedImage` with an `url` and custom options. 68 | * 69 | * The download is asynchronous and cached. 70 | * 71 | * @param url The url for the image. 72 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 73 | * @param progressBlock A block called while image is downloading 74 | * @param completedBlock A block called when operation has been completed. This block has no return value 75 | * and takes the requested UIImage as first parameter. In case of error the image parameter 76 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 77 | * indicating if the image was retrived from the local cache of from the network. 78 | * The forth parameter is the original image url. 79 | */ 80 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 81 | 82 | /** 83 | * Cancel the current download 84 | */ 85 | - (void)sd_cancelCurrentHighlightedImageLoad; 86 | 87 | @end 88 | 89 | 90 | @interface UIImageView (HighlightedWebCacheDeprecated) 91 | 92 | - (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`"); 93 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`"); 94 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`"); 95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); 96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); 97 | 98 | - (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIImage+GIF.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.m 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "UIImage+GIF.h" 10 | #import 11 | 12 | @implementation UIImage (GIF) 13 | 14 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data { 15 | if (!data) { 16 | return nil; 17 | } 18 | 19 | CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); 20 | 21 | size_t count = CGImageSourceGetCount(source); 22 | 23 | UIImage *animatedImage; 24 | 25 | if (count <= 1) { 26 | animatedImage = [[UIImage alloc] initWithData:data]; 27 | } 28 | else { 29 | NSMutableArray *images = [NSMutableArray array]; 30 | 31 | NSTimeInterval duration = 0.0f; 32 | 33 | for (size_t i = 0; i < count; i++) { 34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); 35 | 36 | duration += [self sd_frameDurationAtIndex:i source:source]; 37 | 38 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; 39 | 40 | CGImageRelease(image); 41 | } 42 | 43 | if (!duration) { 44 | duration = (1.0f / 10.0f) * count; 45 | } 46 | 47 | animatedImage = [UIImage animatedImageWithImages:images duration:duration]; 48 | } 49 | 50 | CFRelease(source); 51 | 52 | return animatedImage; 53 | } 54 | 55 | + (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { 56 | float frameDuration = 0.1f; 57 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); 58 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; 59 | NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; 60 | 61 | NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; 62 | if (delayTimeUnclampedProp) { 63 | frameDuration = [delayTimeUnclampedProp floatValue]; 64 | } 65 | else { 66 | 67 | NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; 68 | if (delayTimeProp) { 69 | frameDuration = [delayTimeProp floatValue]; 70 | } 71 | } 72 | 73 | // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. 74 | // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify 75 | // a duration of <= 10 ms. See and 76 | // for more information. 77 | 78 | if (frameDuration < 0.011f) { 79 | frameDuration = 0.100f; 80 | } 81 | 82 | CFRelease(cfFrameProperties); 83 | return frameDuration; 84 | } 85 | 86 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name { 87 | CGFloat scale = [UIScreen mainScreen].scale; 88 | 89 | if (scale > 1.0f) { 90 | NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"]; 91 | 92 | NSData *data = [NSData dataWithContentsOfFile:retinaPath]; 93 | 94 | if (data) { 95 | return [UIImage sd_animatedGIFWithData:data]; 96 | } 97 | 98 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 99 | 100 | data = [NSData dataWithContentsOfFile:path]; 101 | 102 | if (data) { 103 | return [UIImage sd_animatedGIFWithData:data]; 104 | } 105 | 106 | return [UIImage imageNamed:name]; 107 | } 108 | else { 109 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 110 | 111 | NSData *data = [NSData dataWithContentsOfFile:path]; 112 | 113 | if (data) { 114 | return [UIImage sd_animatedGIFWithData:data]; 115 | } 116 | 117 | return [UIImage imageNamed:name]; 118 | } 119 | } 120 | 121 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size { 122 | if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) { 123 | return self; 124 | } 125 | 126 | CGSize scaledSize = size; 127 | CGPoint thumbnailPoint = CGPointZero; 128 | 129 | CGFloat widthFactor = size.width / self.size.width; 130 | CGFloat heightFactor = size.height / self.size.height; 131 | CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor; 132 | scaledSize.width = self.size.width * scaleFactor; 133 | scaledSize.height = self.size.height * scaleFactor; 134 | 135 | if (widthFactor > heightFactor) { 136 | thumbnailPoint.y = (size.height - scaledSize.height) * 0.5; 137 | } 138 | else if (widthFactor < heightFactor) { 139 | thumbnailPoint.x = (size.width - scaledSize.width) * 0.5; 140 | } 141 | 142 | NSMutableArray *scaledImages = [NSMutableArray array]; 143 | 144 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); 145 | 146 | for (UIImage *image in self.images) { 147 | [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)]; 148 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 149 | 150 | [scaledImages addObject:newImage]; 151 | } 152 | 153 | UIGraphicsEndImageContext(); 154 | 155 | return [UIImage animatedImageWithImages:scaledImages duration:self.duration]; 156 | } 157 | 158 | @end 159 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.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 "SDWebImagePrefetcher.h" 10 | 11 | #if !defined(DEBUG) && !defined (SD_VERBOSE) 12 | #define NSLog(...) 13 | #endif 14 | 15 | @interface SDWebImagePrefetcher () 16 | 17 | @property (strong, nonatomic) SDWebImageManager *manager; 18 | @property (strong, nonatomic) NSArray *prefetchURLs; 19 | @property (assign, nonatomic) NSUInteger requestedCount; 20 | @property (assign, nonatomic) NSUInteger skippedCount; 21 | @property (assign, nonatomic) NSUInteger finishedCount; 22 | @property (assign, nonatomic) NSTimeInterval startedTime; 23 | @property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock; 24 | @property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock; 25 | 26 | @end 27 | 28 | @implementation SDWebImagePrefetcher 29 | 30 | + (SDWebImagePrefetcher *)sharedImagePrefetcher { 31 | static dispatch_once_t once; 32 | static id instance; 33 | dispatch_once(&once, ^{ 34 | instance = [self new]; 35 | }); 36 | return instance; 37 | } 38 | 39 | - (id)init { 40 | if ((self = [super init])) { 41 | _manager = [SDWebImageManager new]; 42 | _options = SDWebImageLowPriority; 43 | self.maxConcurrentDownloads = 3; 44 | } 45 | return self; 46 | } 47 | 48 | - (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { 49 | self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; 50 | } 51 | 52 | - (NSUInteger)maxConcurrentDownloads { 53 | return self.manager.imageDownloader.maxConcurrentDownloads; 54 | } 55 | 56 | - (void)startPrefetchingAtIndex:(NSUInteger)index { 57 | if (index >= self.prefetchURLs.count) return; 58 | self.requestedCount++; 59 | [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 60 | if (!finished) return; 61 | self.finishedCount++; 62 | 63 | if (image) { 64 | if (self.progressBlock) { 65 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 66 | } 67 | NSLog(@"Prefetched %@ out of %@", @(self.finishedCount), @(self.prefetchURLs.count)); 68 | } 69 | else { 70 | if (self.progressBlock) { 71 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 72 | } 73 | NSLog(@"Prefetched %@ out of %@ (Failed)", @(self.finishedCount), @(self.prefetchURLs.count)); 74 | 75 | // Add last failed 76 | self.skippedCount++; 77 | } 78 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { 79 | [self.delegate imagePrefetcher:self 80 | didPrefetchURL:self.prefetchURLs[index] 81 | finishedCount:self.finishedCount 82 | totalCount:self.prefetchURLs.count 83 | ]; 84 | } 85 | 86 | if (self.prefetchURLs.count > self.requestedCount) { 87 | dispatch_async(dispatch_get_main_queue(), ^{ 88 | [self startPrefetchingAtIndex:self.requestedCount]; 89 | }); 90 | } 91 | else if (self.finishedCount == self.requestedCount) { 92 | [self reportStatus]; 93 | if (self.completionBlock) { 94 | self.completionBlock(self.finishedCount, self.skippedCount); 95 | self.completionBlock = nil; 96 | } 97 | } 98 | }]; 99 | } 100 | 101 | - (void)reportStatus { 102 | NSUInteger total = [self.prefetchURLs count]; 103 | NSLog(@"Finished prefetching (%@ successful, %@ skipped, timeElasped %.2f)", @(total - self.skippedCount), @(self.skippedCount), CFAbsoluteTimeGetCurrent() - self.startedTime); 104 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { 105 | [self.delegate imagePrefetcher:self 106 | didFinishWithTotalCount:(total - self.skippedCount) 107 | skippedCount:self.skippedCount 108 | ]; 109 | } 110 | } 111 | 112 | - (void)prefetchURLs:(NSArray *)urls { 113 | [self prefetchURLs:urls progress:nil completed:nil]; 114 | } 115 | 116 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock { 117 | [self cancelPrefetching]; // Prevent duplicate prefetch request 118 | self.startedTime = CFAbsoluteTimeGetCurrent(); 119 | self.prefetchURLs = urls; 120 | self.completionBlock = completionBlock; 121 | self.progressBlock = progressBlock; 122 | 123 | // Starts prefetching from the very first image on the list with the max allowed concurrency 124 | NSUInteger listCount = self.prefetchURLs.count; 125 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { 126 | [self startPrefetchingAtIndex:i]; 127 | } 128 | } 129 | 130 | - (void)cancelPrefetching { 131 | self.prefetchURLs = nil; 132 | self.skippedCount = 0; 133 | self.requestedCount = 0; 134 | self.finishedCount = 0; 135 | [self.manager cancelAll]; 136 | } 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.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 "SDWebImageOperation.h" 12 | 13 | typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { 14 | SDWebImageDownloaderLowPriority = 1 << 0, 15 | SDWebImageDownloaderProgressiveDownload = 1 << 1, 16 | 17 | /** 18 | * By default, request prevent the of NSURLCache. With this flag, NSURLCache 19 | * is used with default policies. 20 | */ 21 | SDWebImageDownloaderUseNSURLCache = 1 << 2, 22 | 23 | /** 24 | * Call completion block with nil image/imageData if the image was read from NSURLCache 25 | * (to be combined with `SDWebImageDownloaderUseNSURLCache`). 26 | */ 27 | 28 | SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, 29 | /** 30 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for 31 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled. 32 | */ 33 | 34 | SDWebImageDownloaderContinueInBackground = 1 << 4, 35 | 36 | /** 37 | * Handles cookies stored in NSHTTPCookieStore by setting 38 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES; 39 | */ 40 | SDWebImageDownloaderHandleCookies = 1 << 5, 41 | 42 | /** 43 | * Enable to allow untrusted SSL ceriticates. 44 | * Useful for testing purposes. Use with caution in production. 45 | */ 46 | SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, 47 | 48 | /** 49 | * Put the image in the high priority queue. 50 | */ 51 | SDWebImageDownloaderHighPriority = 1 << 7, 52 | 53 | 54 | }; 55 | 56 | typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { 57 | /** 58 | * Default value. All download operations will execute in queue style (first-in-first-out). 59 | */ 60 | SDWebImageDownloaderFIFOExecutionOrder, 61 | 62 | /** 63 | * All download operations will execute in stack style (last-in-first-out). 64 | */ 65 | SDWebImageDownloaderLIFOExecutionOrder 66 | }; 67 | 68 | extern NSString *const SDWebImageDownloadStartNotification; 69 | extern NSString *const SDWebImageDownloadStopNotification; 70 | 71 | typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); 72 | 73 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); 74 | 75 | typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDictionary *headers); 76 | 77 | /** 78 | * Asynchronous downloader dedicated and optimized for image loading. 79 | */ 80 | @interface SDWebImageDownloader : NSObject 81 | 82 | @property (assign, nonatomic) NSInteger maxConcurrentDownloads; 83 | 84 | /** 85 | * Shows the current amount of downloads that still need to be downloaded 86 | */ 87 | 88 | @property (readonly, nonatomic) NSUInteger currentDownloadCount; 89 | 90 | 91 | /** 92 | * The timeout value (in seconds) for the download operation. Default: 15.0. 93 | */ 94 | @property (assign, nonatomic) NSTimeInterval downloadTimeout; 95 | 96 | 97 | /** 98 | * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. 99 | */ 100 | @property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; 101 | 102 | /** 103 | * Singleton method, returns the shared instance 104 | * 105 | * @return global shared instance of downloader class 106 | */ 107 | + (SDWebImageDownloader *)sharedDownloader; 108 | 109 | /** 110 | * Set username 111 | */ 112 | @property (strong, nonatomic) NSString *username; 113 | 114 | /** 115 | * Set password 116 | */ 117 | @property (strong, nonatomic) NSString *password; 118 | 119 | /** 120 | * Set filter to pick headers for downloading image HTTP request. 121 | * 122 | * This block will be invoked for each downloading image request, returned 123 | * NSDictionary will be used as headers in corresponding HTTP request. 124 | */ 125 | @property (nonatomic, copy) SDWebImageDownloaderHeadersFilterBlock headersFilter; 126 | 127 | /** 128 | * Set a value for a HTTP header to be appended to each download HTTP request. 129 | * 130 | * @param value The value for the header field. Use `nil` value to remove the header. 131 | * @param field The name of the header field to set. 132 | */ 133 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field; 134 | 135 | /** 136 | * Returns the value of the specified HTTP header field. 137 | * 138 | * @return The value associated with the header field field, or `nil` if there is no corresponding header field. 139 | */ 140 | - (NSString *)valueForHTTPHeaderField:(NSString *)field; 141 | 142 | /** 143 | * Creates a SDWebImageDownloader async downloader instance with a given URL 144 | * 145 | * The delegate will be informed when the image is finish downloaded or an error has happen. 146 | * 147 | * @see SDWebImageDownloaderDelegate 148 | * 149 | * @param url The URL to the image to download 150 | * @param options The options to be used for this download 151 | * @param progressBlock A block called repeatedly while the image is downloading 152 | * @param completedBlock A block called once the download is completed. 153 | * If the download succeeded, the image parameter is set, in case of error, 154 | * error parameter is set with the error. The last parameter is always YES 155 | * if SDWebImageDownloaderProgressiveDownload isn't use. With the 156 | * SDWebImageDownloaderProgressiveDownload option, this block is called 157 | * repeatedly with the partial image object and the finished argument set to NO 158 | * before to be called a last time with the full image and finished argument 159 | * set to YES. In case of error, the finished argument is always YES. 160 | * 161 | * @return A cancellable SDWebImageOperation 162 | */ 163 | - (id )downloadImageWithURL:(NSURL *)url 164 | options:(SDWebImageDownloaderOptions)options 165 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 166 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock; 167 | 168 | /** 169 | * Sets the download queue suspension state 170 | */ 171 | - (void)setSuspended:(BOOL)suspended; 172 | 173 | @end 174 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDImageCache.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 NS_ENUM(NSInteger, SDImageCacheType) { 13 | /** 14 | * The image wasn't available the SDWebImage caches, but was downloaded from the web. 15 | */ 16 | SDImageCacheTypeNone, 17 | /** 18 | * The image was obtained from the disk cache. 19 | */ 20 | SDImageCacheTypeDisk, 21 | /** 22 | * The image was obtained from the memory cache. 23 | */ 24 | SDImageCacheTypeMemory 25 | }; 26 | 27 | typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType); 28 | 29 | typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache); 30 | 31 | typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); 32 | 33 | /** 34 | * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed 35 | * asynchronous so it doesn’t add unnecessary latency to the UI. 36 | */ 37 | @interface SDImageCache : NSObject 38 | 39 | /** 40 | * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. 41 | */ 42 | @property (assign, nonatomic) NSUInteger maxMemoryCost; 43 | 44 | /** 45 | * The maximum length of time to keep an image in the cache, in seconds 46 | */ 47 | @property (assign, nonatomic) NSInteger maxCacheAge; 48 | 49 | /** 50 | * The maximum size of the cache, in bytes. 51 | */ 52 | @property (assign, nonatomic) NSUInteger maxCacheSize; 53 | 54 | /** 55 | * Returns global shared cache instance 56 | * 57 | * @return SDImageCache global instance 58 | */ 59 | + (SDImageCache *)sharedImageCache; 60 | 61 | /** 62 | * Init a new cache store with a specific namespace 63 | * 64 | * @param ns The namespace to use for this cache store 65 | */ 66 | - (id)initWithNamespace:(NSString *)ns; 67 | 68 | /** 69 | * Add a read-only cache path to search for images pre-cached by SDImageCache 70 | * Useful if you want to bundle pre-loaded images with your app 71 | * 72 | * @param path The path to use for this read-only cache path 73 | */ 74 | - (void)addReadOnlyCachePath:(NSString *)path; 75 | 76 | /** 77 | * Store an image into memory and disk cache at the given key. 78 | * 79 | * @param image The image to store 80 | * @param key The unique image cache key, usually it's image absolute URL 81 | */ 82 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key; 83 | 84 | /** 85 | * Store an image into memory and optionally disk cache at the given key. 86 | * 87 | * @param image The image to store 88 | * @param key The unique image cache key, usually it's image absolute URL 89 | * @param toDisk Store the image to disk cache if YES 90 | */ 91 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk; 92 | 93 | /** 94 | * Store an image into memory and optionally disk cache at the given key. 95 | * 96 | * @param image The image to store 97 | * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage 98 | * @param imageData The image data as returned by the server, this representation will be used for disk storage 99 | * instead of converting the given image object into a storable/compressed image format in order 100 | * to save quality and CPU 101 | * @param key The unique image cache key, usually it's image absolute URL 102 | * @param toDisk Store the image to disk cache if YES 103 | */ 104 | - (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk; 105 | 106 | /** 107 | * Query the disk cache asynchronously. 108 | * 109 | * @param key The unique key used to store the wanted image 110 | */ 111 | - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock; 112 | 113 | /** 114 | * Query the memory cache synchronously. 115 | * 116 | * @param key The unique key used to store the wanted image 117 | */ 118 | - (UIImage *)imageFromMemoryCacheForKey:(NSString *)key; 119 | 120 | /** 121 | * Query the disk cache synchronously after checking the memory cache. 122 | * 123 | * @param key The unique key used to store the wanted image 124 | */ 125 | - (UIImage *)imageFromDiskCacheForKey:(NSString *)key; 126 | 127 | /** 128 | * Remove the image from memory and disk cache synchronously 129 | * 130 | * @param key The unique image cache key 131 | */ 132 | - (void)removeImageForKey:(NSString *)key; 133 | 134 | 135 | /** 136 | * Remove the image from memory and disk cache synchronously 137 | * 138 | * @param key The unique image cache key 139 | * @param completionBlock An block that should be executed after the image has been removed (optional) 140 | */ 141 | - (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion; 142 | 143 | /** 144 | * Remove the image from memory and optionally disk cache synchronously 145 | * 146 | * @param key The unique image cache key 147 | * @param fromDisk Also remove cache entry from disk if YES 148 | */ 149 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk; 150 | 151 | /** 152 | * Remove the image from memory and optionally disk cache synchronously 153 | * 154 | * @param key The unique image cache key 155 | * @param fromDisk Also remove cache entry from disk if YES 156 | * @param completionBlock An block that should be executed after the image has been removed (optional) 157 | */ 158 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion; 159 | 160 | /** 161 | * Clear all memory cached images 162 | */ 163 | - (void)clearMemory; 164 | 165 | /** 166 | * Clear all disk cached images. Non-blocking method - returns immediately. 167 | * @param completionBlock An block that should be executed after cache expiration completes (optional) 168 | */ 169 | - (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion; 170 | 171 | /** 172 | * Clear all disk cached images 173 | * @see clearDiskOnCompletion: 174 | */ 175 | - (void)clearDisk; 176 | 177 | /** 178 | * Remove all expired cached image from disk. Non-blocking method - returns immediately. 179 | * @param completionBlock An block that should be executed after cache expiration completes (optional) 180 | */ 181 | - (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock; 182 | 183 | /** 184 | * Remove all expired cached image from disk 185 | * @see cleanDiskWithCompletionBlock: 186 | */ 187 | - (void)cleanDisk; 188 | 189 | /** 190 | * Get the size used by the disk cache 191 | */ 192 | - (NSUInteger)getSize; 193 | 194 | /** 195 | * Get the number of images in the disk cache 196 | */ 197 | - (NSUInteger)getDiskCount; 198 | 199 | /** 200 | * Asynchronously calculate the disk cache's size. 201 | */ 202 | - (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock; 203 | 204 | /** 205 | * Async check if image exists in disk cache already (does not load the image) 206 | * 207 | * @param key the key describing the url 208 | * @param completionBlock the block to be executed when the check is done. 209 | * @note the completion block will be always executed on the main queue 210 | */ 211 | - (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 212 | 213 | /** 214 | * Check if image exists in disk cache already (does not load the image) 215 | * 216 | * @param key the key describing the url 217 | * 218 | * @return YES if an image exists for the given key 219 | */ 220 | - (BOOL)diskImageExistsWithKey:(NSString *)key; 221 | 222 | /** 223 | * Get the cache path for a certain key (needs the cache path root folder) 224 | * 225 | * @param key the key (can be obtained from url using cacheKeyForURL) 226 | * @param path the cach path root folder 227 | * 228 | * @return the cache path 229 | */ 230 | - (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path; 231 | 232 | /** 233 | * Get the default cache path for a certain key 234 | * 235 | * @param key the key (can be obtained from url using cacheKeyForURL) 236 | * 237 | * @return the default cache path 238 | */ 239 | - (NSString *)defaultCachePathForKey:(NSString *)key; 240 | 241 | @end 242 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.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 "UIImageView+WebCache.h" 10 | #import "objc/runtime.h" 11 | #import "UIView+WebCacheOperation.h" 12 | 13 | static char imageURLKey; 14 | 15 | @implementation UIImageView (WebCache) 16 | 17 | - (void)sd_setImageWithURL:(NSURL *)url { 18 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; 19 | } 20 | 21 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { 22 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; 23 | } 24 | 25 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 26 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; 27 | } 28 | 29 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { 30 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; 31 | } 32 | 33 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { 34 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; 35 | } 36 | 37 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 38 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; 39 | } 40 | 41 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { 42 | [self sd_cancelCurrentImageLoad]; 43 | objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | 45 | if (!(options & SDWebImageDelayPlaceholder)) { 46 | self.image = placeholder; 47 | } 48 | 49 | if (url) { 50 | __weak UIImageView *wself = self; 51 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 52 | if (!wself) return; 53 | dispatch_main_sync_safe(^{ 54 | if (!wself) return; 55 | if (image) { 56 | wself.image = image; 57 | [wself setNeedsLayout]; 58 | } else { 59 | if ((options & SDWebImageDelayPlaceholder)) { 60 | wself.image = placeholder; 61 | [wself setNeedsLayout]; 62 | } 63 | } 64 | if (completedBlock && finished) { 65 | completedBlock(image, error, cacheType, url); 66 | } 67 | }); 68 | }]; 69 | [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; 70 | } else { 71 | dispatch_main_async_safe(^{ 72 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 73 | if (completedBlock) { 74 | completedBlock(nil, error, SDImageCacheTypeNone, url); 75 | } 76 | }); 77 | } 78 | } 79 | 80 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { 81 | NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url]; 82 | UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key]; 83 | 84 | [self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock]; 85 | } 86 | 87 | - (NSURL *)sd_imageURL { 88 | return objc_getAssociatedObject(self, &imageURLKey); 89 | } 90 | 91 | - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { 92 | [self sd_cancelCurrentAnimationImagesLoad]; 93 | __weak UIImageView *wself = self; 94 | 95 | NSMutableArray *operationsArray = [[NSMutableArray alloc] init]; 96 | 97 | for (NSURL *logoImageURL in arrayOfURLs) { 98 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 99 | if (!wself) return; 100 | dispatch_main_sync_safe(^{ 101 | __strong UIImageView *sself = wself; 102 | [sself stopAnimating]; 103 | if (sself && image) { 104 | NSMutableArray *currentImages = [[sself animationImages] mutableCopy]; 105 | if (!currentImages) { 106 | currentImages = [[NSMutableArray alloc] init]; 107 | } 108 | [currentImages addObject:image]; 109 | 110 | sself.animationImages = currentImages; 111 | [sself setNeedsLayout]; 112 | } 113 | [sself startAnimating]; 114 | }); 115 | }]; 116 | [operationsArray addObject:operation]; 117 | } 118 | 119 | [self sd_setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"]; 120 | } 121 | 122 | - (void)sd_cancelCurrentImageLoad { 123 | [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"]; 124 | } 125 | 126 | - (void)sd_cancelCurrentAnimationImagesLoad { 127 | [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; 128 | } 129 | 130 | @end 131 | 132 | 133 | @implementation UIImageView (WebCacheDeprecated) 134 | 135 | - (NSURL *)imageURL { 136 | return [self sd_imageURL]; 137 | } 138 | 139 | - (void)setImageWithURL:(NSURL *)url { 140 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; 141 | } 142 | 143 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { 144 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; 145 | } 146 | 147 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 148 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; 149 | } 150 | 151 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { 152 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 153 | if (completedBlock) { 154 | completedBlock(image, error, cacheType); 155 | } 156 | }]; 157 | } 158 | 159 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { 160 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 161 | if (completedBlock) { 162 | completedBlock(image, error, cacheType); 163 | } 164 | }]; 165 | } 166 | 167 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 168 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 169 | if (completedBlock) { 170 | completedBlock(image, error, cacheType); 171 | } 172 | }]; 173 | } 174 | 175 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { 176 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 177 | if (completedBlock) { 178 | completedBlock(image, error, cacheType); 179 | } 180 | }]; 181 | } 182 | 183 | - (void)cancelCurrentArrayLoad { 184 | [self sd_cancelCurrentAnimationImagesLoad]; 185 | } 186 | 187 | - (void)cancelCurrentImageLoad { 188 | [self sd_cancelCurrentImageLoad]; 189 | } 190 | 191 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { 192 | [self sd_setAnimationImagesWithURLs:arrayOfURLs]; 193 | } 194 | 195 | @end 196 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.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 "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView. 14 | * 15 | * Usage with a UITableViewCell sub-class: 16 | * 17 | * @code 18 | 19 | #import 20 | 21 | ... 22 | 23 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 24 | { 25 | static NSString *MyIdentifier = @"MyIdentifier"; 26 | 27 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 28 | 29 | if (cell == nil) { 30 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] 31 | autorelease]; 32 | } 33 | 34 | // Here we use the provided sd_setImageWithURL: method to load the web image 35 | // Ensure you use a placeholder image otherwise cells will be initialized with no image 36 | [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] 37 | placeholderImage:[UIImage imageNamed:@"placeholder"]]; 38 | 39 | cell.textLabel.text = @"My Text"; 40 | return cell; 41 | } 42 | 43 | * @endcode 44 | */ 45 | @interface UIImageView (WebCache) 46 | 47 | /** 48 | * Get the current image URL. 49 | * 50 | * Note that because of the limitations of categories this property can get out of sync 51 | * if you use sd_setImage: directly. 52 | */ 53 | - (NSURL *)sd_imageURL; 54 | 55 | /** 56 | * Set the imageView `image` with an `url`. 57 | * 58 | * The download is asynchronous and cached. 59 | * 60 | * @param url The url for the image. 61 | */ 62 | - (void)sd_setImageWithURL:(NSURL *)url; 63 | 64 | /** 65 | * Set the imageView `image` with an `url` and a placeholder. 66 | * 67 | * The download is asynchronous and cached. 68 | * 69 | * @param url The url for the image. 70 | * @param placeholder The image to be set initially, until the image request finishes. 71 | * @see sd_setImageWithURL:placeholderImage:options: 72 | */ 73 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; 74 | 75 | /** 76 | * Set the imageView `image` with an `url`, placeholder and custom options. 77 | * 78 | * The download is asynchronous and cached. 79 | * 80 | * @param url The url for the image. 81 | * @param placeholder The image to be set initially, until the image request finishes. 82 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 83 | */ 84 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 85 | 86 | /** 87 | * Set the imageView `image` with an `url`. 88 | * 89 | * The download is asynchronous and cached. 90 | * 91 | * @param url The url for the image. 92 | * @param completedBlock A block called when operation has been completed. This block has no return value 93 | * and takes the requested UIImage as first parameter. In case of error the image parameter 94 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 95 | * indicating if the image was retrived from the local cache of from the network. 96 | * The forth parameter is the original image url. 97 | */ 98 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 99 | 100 | /** 101 | * Set the imageView `image` with an `url`, placeholder. 102 | * 103 | * The download is asynchronous and cached. 104 | * 105 | * @param url The url for the image. 106 | * @param placeholder The image to be set initially, until the image request finishes. 107 | * @param completedBlock A block called when operation has been completed. This block has no return value 108 | * and takes the requested UIImage as first parameter. In case of error the image parameter 109 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 110 | * indicating if the image was retrived from the local cache of from the network. 111 | * The forth parameter is the original image url. 112 | */ 113 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; 114 | 115 | /** 116 | * Set the imageView `image` with an `url`, placeholder and custom options. 117 | * 118 | * The download is asynchronous and cached. 119 | * 120 | * @param url The url for the image. 121 | * @param placeholder The image to be set initially, until the image request finishes. 122 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 123 | * @param completedBlock A block called when operation has been completed. This block has no return value 124 | * and takes the requested UIImage as first parameter. In case of error the image parameter 125 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 126 | * indicating if the image was retrived from the local cache of from the network. 127 | * The forth parameter is the original image url. 128 | */ 129 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 130 | 131 | /** 132 | * Set the imageView `image` with an `url`, placeholder and custom options. 133 | * 134 | * The download is asynchronous and cached. 135 | * 136 | * @param url The url for the image. 137 | * @param placeholder The image to be set initially, until the image request finishes. 138 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 139 | * @param progressBlock A block called while image is downloading 140 | * @param completedBlock A block called when operation has been completed. This block has no return value 141 | * and takes the requested UIImage as first parameter. In case of error the image parameter 142 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 143 | * indicating if the image was retrived from the local cache of from the network. 144 | * The forth parameter is the original image url. 145 | */ 146 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 147 | 148 | /** 149 | * Set the imageView `image` with an `url` and a optionaly placeholder image. 150 | * 151 | * The download is asynchronous and cached. 152 | * 153 | * @param url The url for the image. 154 | * @param placeholder The image to be set initially, until the image request finishes. 155 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 156 | * @param progressBlock A block called while image is downloading 157 | * @param completedBlock A block called when operation has been completed. This block has no return value 158 | * and takes the requested UIImage as first parameter. In case of error the image parameter 159 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 160 | * indicating if the image was retrived from the local cache of from the network. 161 | * The forth parameter is the original image url. 162 | */ 163 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 164 | 165 | /** 166 | * Download an array of images and starts them in an animation loop 167 | * 168 | * @param arrayOfURLs An array of NSURL 169 | */ 170 | - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; 171 | 172 | /** 173 | * Cancel the current download 174 | */ 175 | - (void)sd_cancelCurrentImageLoad; 176 | 177 | - (void)sd_cancelCurrentAnimationImagesLoad; 178 | 179 | @end 180 | 181 | 182 | @interface UIImageView (WebCacheDeprecated) 183 | 184 | - (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); 185 | 186 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); 187 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); 188 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`"); 189 | 190 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); 191 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); 192 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); 193 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`"); 194 | 195 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`"); 196 | 197 | - (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`"); 198 | 199 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); 200 | 201 | @end 202 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImageManager.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 | #import "SDWebImageDownloader.h" 12 | #import "SDImageCache.h" 13 | 14 | typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { 15 | /** 16 | * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. 17 | * This flag disable this blacklisting. 18 | */ 19 | SDWebImageRetryFailed = 1 << 0, 20 | 21 | /** 22 | * By default, image downloads are started during UI interactions, this flags disable this feature, 23 | * leading to delayed download on UIScrollView deceleration for instance. 24 | */ 25 | SDWebImageLowPriority = 1 << 1, 26 | 27 | /** 28 | * This flag disables on-disk caching 29 | */ 30 | SDWebImageCacheMemoryOnly = 1 << 2, 31 | 32 | /** 33 | * This flag enables progressive download, the image is displayed progressively during download as a browser would do. 34 | * By default, the image is only displayed once completely downloaded. 35 | */ 36 | SDWebImageProgressiveDownload = 1 << 3, 37 | 38 | /** 39 | * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. 40 | * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. 41 | * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. 42 | * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. 43 | * 44 | * Use this flag only if you can't make your URLs static with embeded cache busting parameter. 45 | */ 46 | SDWebImageRefreshCached = 1 << 4, 47 | 48 | /** 49 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for 50 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled. 51 | */ 52 | SDWebImageContinueInBackground = 1 << 5, 53 | 54 | /** 55 | * Handles cookies stored in NSHTTPCookieStore by setting 56 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES; 57 | */ 58 | SDWebImageHandleCookies = 1 << 6, 59 | 60 | /** 61 | * Enable to allow untrusted SSL ceriticates. 62 | * Useful for testing purposes. Use with caution in production. 63 | */ 64 | SDWebImageAllowInvalidSSLCertificates = 1 << 7, 65 | 66 | /** 67 | * By default, image are loaded in the order they were queued. This flag move them to 68 | * the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which 69 | * could take a while). 70 | */ 71 | SDWebImageHighPriority = 1 << 8, 72 | 73 | /** 74 | * By default, placeholder images are loaded while the image is loading. This flag will delay the loading 75 | * of the placeholder image until after the image has finished loading. 76 | */ 77 | SDWebImageDelayPlaceholder = 1 << 9 78 | }; 79 | 80 | typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL); 81 | 82 | typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL); 83 | 84 | typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url); 85 | 86 | 87 | @class SDWebImageManager; 88 | 89 | @protocol SDWebImageManagerDelegate 90 | 91 | @optional 92 | 93 | /** 94 | * Controls which image should be downloaded when the image is not found in the cache. 95 | * 96 | * @param imageManager The current `SDWebImageManager` 97 | * @param imageURL The url of the image to be downloaded 98 | * 99 | * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied. 100 | */ 101 | - (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL; 102 | 103 | /** 104 | * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory. 105 | * NOTE: This method is called from a global queue in order to not to block the main thread. 106 | * 107 | * @param imageManager The current `SDWebImageManager` 108 | * @param image The image to transform 109 | * @param imageURL The url of the image to transform 110 | * 111 | * @return The transformed image object. 112 | */ 113 | - (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL; 114 | 115 | @end 116 | 117 | /** 118 | * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes. 119 | * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache). 120 | * You can use this class directly to benefit from web image downloading with caching in another context than 121 | * a UIView. 122 | * 123 | * Here is a simple example of how to use SDWebImageManager: 124 | * 125 | * @code 126 | 127 | SDWebImageManager *manager = [SDWebImageManager sharedManager]; 128 | [manager downloadWithURL:imageURL 129 | options:0 130 | progress:nil 131 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 132 | if (image) { 133 | // do something with image 134 | } 135 | }]; 136 | 137 | * @endcode 138 | */ 139 | @interface SDWebImageManager : NSObject 140 | 141 | @property (weak, nonatomic) id delegate; 142 | 143 | @property (strong, nonatomic, readonly) SDImageCache *imageCache; 144 | @property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader; 145 | 146 | /** 147 | * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can 148 | * be used to remove dynamic part of an image URL. 149 | * 150 | * The following example sets a filter in the application delegate that will remove any query-string from the 151 | * URL before to use it as a cache key: 152 | * 153 | * @code 154 | 155 | [[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) { 156 | url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; 157 | return [url absoluteString]; 158 | }]; 159 | 160 | * @endcode 161 | */ 162 | @property (copy) SDWebImageCacheKeyFilterBlock cacheKeyFilter; 163 | 164 | /** 165 | * Returns global SDWebImageManager instance. 166 | * 167 | * @return SDWebImageManager shared instance 168 | */ 169 | + (SDWebImageManager *)sharedManager; 170 | 171 | /** 172 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise. 173 | * 174 | * @param url The URL to the image 175 | * @param options A mask to specify options to use for this request 176 | * @param progressBlock A block called while image is downloading 177 | * @param completedBlock A block called when operation has been completed. 178 | * 179 | * This parameter is required. 180 | * 181 | * This block has no return value and takes the requested UIImage as first parameter. 182 | * In case of error the image parameter is nil and the second parameter may contain an NSError. 183 | * 184 | * The third parameter is an `SDImageCacheType` enum indicating if the image was retrived from the local cache 185 | * or from the memory cache or from the network. 186 | * 187 | * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is 188 | * downloading. This block is thus called repetidly with a partial image. When image is fully downloaded, the 189 | * block is called a last time with the full image and the last parameter set to YES. 190 | * 191 | * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation 192 | */ 193 | - (id )downloadImageWithURL:(NSURL *)url 194 | options:(SDWebImageOptions)options 195 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 196 | completed:(SDWebImageCompletionWithFinishedBlock)completedBlock; 197 | 198 | /** 199 | * Saves image to cache for given URL 200 | * 201 | * @param image The image to cache 202 | * @param url The URL to the image 203 | * 204 | */ 205 | 206 | - (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url; 207 | 208 | /** 209 | * Cancel all current opreations 210 | */ 211 | - (void)cancelAll; 212 | 213 | /** 214 | * Check one or more operations running 215 | */ 216 | - (BOOL)isRunning; 217 | 218 | /** 219 | * Check if image has already been cached 220 | * 221 | * @param url image url 222 | * 223 | * @return if the image was already cached 224 | */ 225 | - (BOOL)cachedImageExistsForURL:(NSURL *)url; 226 | 227 | /** 228 | * Check if image has already been cached on disk only 229 | * 230 | * @param url image url 231 | * 232 | * @return if the image was already cached (disk only) 233 | */ 234 | - (BOOL)diskImageExistsForURL:(NSURL *)url; 235 | 236 | /** 237 | * Async check if image has already been cached 238 | * 239 | * @param url image url 240 | * @param completionBlock the block to be executed when the check is finished 241 | * 242 | * @note the completion block is always executed on the main queue 243 | */ 244 | - (void)cachedImageExistsForURL:(NSURL *)url 245 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 246 | 247 | /** 248 | * Async check if image has already been cached on disk only 249 | * 250 | * @param url image url 251 | * @param completionBlock the block to be executed when the check is finished 252 | * 253 | * @note the completion block is always executed on the main queue 254 | */ 255 | - (void)diskImageExistsForURL:(NSURL *)url 256 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 257 | 258 | 259 | /** 260 | *Return the cache key for a given URL 261 | */ 262 | - (NSString *)cacheKeyForURL:(NSURL *)url; 263 | 264 | @end 265 | 266 | 267 | #pragma mark - Deprecated 268 | 269 | typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionBlock`"); 270 | typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionWithFinishedBlock`"); 271 | 272 | 273 | @interface SDWebImageManager (Deprecated) 274 | 275 | /** 276 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise. 277 | * 278 | * @deprecated This method has been deprecated. Use `downloadImageWithURL:options:progress:completed:` 279 | */ 280 | - (id )downloadWithURL:(NSURL *)url 281 | options:(SDWebImageOptions)options 282 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 283 | completed:(SDWebImageCompletedWithFinishedBlock)completedBlock __deprecated_msg("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`"); 284 | 285 | @end 286 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.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 "SDWebImageDownloader.h" 10 | #import "SDWebImageDownloaderOperation.h" 11 | #import 12 | 13 | NSString *const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification"; 14 | NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification"; 15 | 16 | static NSString *const kProgressCallbackKey = @"progress"; 17 | static NSString *const kCompletedCallbackKey = @"completed"; 18 | 19 | @interface SDWebImageDownloader () 20 | 21 | @property (strong, nonatomic) NSOperationQueue *downloadQueue; 22 | @property (weak, nonatomic) NSOperation *lastAddedOperation; 23 | @property (strong, nonatomic) NSMutableDictionary *URLCallbacks; 24 | @property (strong, nonatomic) NSMutableDictionary *HTTPHeaders; 25 | // This queue is used to serialize the handling of the network responses of all the download operation in a single queue 26 | @property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t barrierQueue; 27 | 28 | @end 29 | 30 | @implementation SDWebImageDownloader 31 | 32 | + (void)initialize { 33 | // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator ) 34 | // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import 35 | if (NSClassFromString(@"SDNetworkActivityIndicator")) { 36 | 37 | #pragma clang diagnostic push 38 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 39 | id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")]; 40 | #pragma clang diagnostic pop 41 | 42 | // Remove observer in case it was previously added. 43 | [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil]; 44 | [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil]; 45 | 46 | [[NSNotificationCenter defaultCenter] addObserver:activityIndicator 47 | selector:NSSelectorFromString(@"startActivity") 48 | name:SDWebImageDownloadStartNotification object:nil]; 49 | [[NSNotificationCenter defaultCenter] addObserver:activityIndicator 50 | selector:NSSelectorFromString(@"stopActivity") 51 | name:SDWebImageDownloadStopNotification object:nil]; 52 | } 53 | } 54 | 55 | + (SDWebImageDownloader *)sharedDownloader { 56 | static dispatch_once_t once; 57 | static id instance; 58 | dispatch_once(&once, ^{ 59 | instance = [self new]; 60 | }); 61 | return instance; 62 | } 63 | 64 | - (id)init { 65 | if ((self = [super init])) { 66 | _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; 67 | _downloadQueue = [NSOperationQueue new]; 68 | _downloadQueue.maxConcurrentOperationCount = 2; 69 | _URLCallbacks = [NSMutableDictionary new]; 70 | _HTTPHeaders = [NSMutableDictionary dictionaryWithObject:@"image/webp,image/*;q=0.8" forKey:@"Accept"]; 71 | _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT); 72 | _downloadTimeout = 15.0; 73 | } 74 | return self; 75 | } 76 | 77 | - (void)dealloc { 78 | [self.downloadQueue cancelAllOperations]; 79 | SDDispatchQueueRelease(_barrierQueue); 80 | } 81 | 82 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field { 83 | if (value) { 84 | self.HTTPHeaders[field] = value; 85 | } 86 | else { 87 | [self.HTTPHeaders removeObjectForKey:field]; 88 | } 89 | } 90 | 91 | - (NSString *)valueForHTTPHeaderField:(NSString *)field { 92 | return self.HTTPHeaders[field]; 93 | } 94 | 95 | - (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads { 96 | _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads; 97 | } 98 | 99 | - (NSUInteger)currentDownloadCount { 100 | return _downloadQueue.operationCount; 101 | } 102 | 103 | - (NSInteger)maxConcurrentDownloads { 104 | return _downloadQueue.maxConcurrentOperationCount; 105 | } 106 | 107 | - (id )downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock { 108 | __block SDWebImageDownloaderOperation *operation; 109 | __weak SDWebImageDownloader *wself = self; 110 | 111 | [self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^{ 112 | NSTimeInterval timeoutInterval = wself.downloadTimeout; 113 | if (timeoutInterval == 0.0) { 114 | timeoutInterval = 15.0; 115 | } 116 | 117 | // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise 118 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval]; 119 | request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies); 120 | request.HTTPShouldUsePipelining = YES; 121 | if (wself.headersFilter) { 122 | request.allHTTPHeaderFields = wself.headersFilter(url, [wself.HTTPHeaders copy]); 123 | } 124 | else { 125 | request.allHTTPHeaderFields = wself.HTTPHeaders; 126 | } 127 | operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request 128 | options:options 129 | progress:^(NSInteger receivedSize, NSInteger expectedSize) { 130 | SDWebImageDownloader *sself = wself; 131 | if (!sself) return; 132 | NSArray *callbacksForURL = [sself callbacksForURL:url]; 133 | for (NSDictionary *callbacks in callbacksForURL) { 134 | SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey]; 135 | if (callback) callback(receivedSize, expectedSize); 136 | } 137 | } 138 | completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { 139 | SDWebImageDownloader *sself = wself; 140 | if (!sself) return; 141 | NSArray *callbacksForURL = [sself callbacksForURL:url]; 142 | if (finished) { 143 | [sself removeCallbacksForURL:url]; 144 | } 145 | for (NSDictionary *callbacks in callbacksForURL) { 146 | SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey]; 147 | if (callback) callback(image, data, error, finished); 148 | } 149 | } 150 | cancelled:^{ 151 | SDWebImageDownloader *sself = wself; 152 | if (!sself) return; 153 | [sself removeCallbacksForURL:url]; 154 | }]; 155 | 156 | if (wself.username && wself.password) { 157 | operation.credential = [NSURLCredential credentialWithUser:wself.username password:wself.password persistence:NSURLCredentialPersistenceForSession]; 158 | } 159 | 160 | if (options & SDWebImageDownloaderHighPriority) { 161 | operation.queuePriority = NSOperationQueuePriorityHigh; 162 | } else if (options & SDWebImageDownloaderLowPriority) { 163 | operation.queuePriority = NSOperationQueuePriorityLow; 164 | } 165 | 166 | [wself.downloadQueue addOperation:operation]; 167 | if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { 168 | // Emulate LIFO execution order by systematically adding new operations as last operation's dependency 169 | [wself.lastAddedOperation addDependency:operation]; 170 | wself.lastAddedOperation = operation; 171 | } 172 | }]; 173 | 174 | return operation; 175 | } 176 | 177 | - (void)addProgressCallback:(SDWebImageDownloaderProgressBlock)progressBlock andCompletedBlock:(SDWebImageDownloaderCompletedBlock)completedBlock forURL:(NSURL *)url createCallback:(SDWebImageNoParamsBlock)createCallback { 178 | // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data. 179 | if (url == nil) { 180 | if (completedBlock != nil) { 181 | completedBlock(nil, nil, nil, NO); 182 | } 183 | return; 184 | } 185 | 186 | dispatch_barrier_sync(self.barrierQueue, ^{ 187 | BOOL first = NO; 188 | if (!self.URLCallbacks[url]) { 189 | self.URLCallbacks[url] = [NSMutableArray new]; 190 | first = YES; 191 | } 192 | 193 | // Handle single download of simultaneous download request for the same URL 194 | NSMutableArray *callbacksForURL = self.URLCallbacks[url]; 195 | NSMutableDictionary *callbacks = [NSMutableDictionary new]; 196 | if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy]; 197 | if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy]; 198 | [callbacksForURL addObject:callbacks]; 199 | self.URLCallbacks[url] = callbacksForURL; 200 | 201 | if (first) { 202 | createCallback(); 203 | } 204 | }); 205 | } 206 | 207 | - (NSArray *)callbacksForURL:(NSURL *)url { 208 | __block NSArray *callbacksForURL; 209 | dispatch_sync(self.barrierQueue, ^{ 210 | callbacksForURL = self.URLCallbacks[url]; 211 | }); 212 | return [callbacksForURL copy]; 213 | } 214 | 215 | - (void)removeCallbacksForURL:(NSURL *)url { 216 | dispatch_barrier_async(self.barrierQueue, ^{ 217 | [self.URLCallbacks removeObjectForKey:url]; 218 | }); 219 | } 220 | 221 | - (void)setSuspended:(BOOL)suspended { 222 | [self.downloadQueue setSuspended:suspended]; 223 | } 224 | 225 | @end 226 | -------------------------------------------------------------------------------- /KDCycleBannerView/KDCycleBannerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KDCycleBannerView.m 3 | // KDCycleBannerViewDemo 4 | // 5 | // Created by Kingiol on 14-4-11. 6 | // Copyright (c) 2014年 Kingiol. All rights reserved. 7 | // 8 | 9 | #import "KDCycleBannerView.h" 10 | 11 | #import 12 | 13 | @interface KDCycleBannerView () 14 | 15 | @property (strong, nonatomic) UIScrollView *scrollView; 16 | @property (assign, nonatomic) BOOL scrollViewBounces; 17 | 18 | @property (strong, nonatomic) UIPageControl *pageControl; 19 | 20 | @property (strong, nonatomic) NSArray *datasourceImages; 21 | @property (assign, nonatomic) NSUInteger currentSelectedPage; 22 | 23 | @property (strong, nonatomic) CompleteBlock completeBlock; 24 | 25 | @end 26 | 27 | @implementation KDCycleBannerView 28 | 29 | static void *kContentImageViewObservationContext = &kContentImageViewObservationContext; 30 | 31 | - (id)initWithFrame:(CGRect)frame 32 | { 33 | self = [super initWithFrame:frame]; 34 | if (self) { 35 | // Initialization code 36 | _scrollViewBounces = YES; 37 | } 38 | return self; 39 | } 40 | 41 | - (id)initWithCoder:(NSCoder *)aDecoder { 42 | if (self = [super initWithCoder:aDecoder]) { 43 | _scrollViewBounces = YES; 44 | } 45 | return self; 46 | } 47 | 48 | - (void)awakeFromNib { 49 | [super awakeFromNib]; 50 | } 51 | 52 | - (void)layoutSubviews { 53 | [super layoutSubviews]; 54 | 55 | NSArray *subViews = self.subviews; 56 | [subViews makeObjectsPerformSelector:@selector(removeFromSuperview)]; 57 | 58 | [self initialize]; 59 | 60 | if (self.completeBlock) { 61 | self.completeBlock(); 62 | } 63 | } 64 | 65 | - (void)initialize { 66 | self.clipsToBounds = YES; 67 | 68 | [self initializeScrollView]; 69 | [self initializePageControl]; 70 | 71 | [self loadData]; 72 | 73 | // progress autoPlayTimeInterval 74 | if (self.autoPlayTimeInterval > 0) { 75 | if ((self.isContinuous && _datasourceImages.count > 3) || (!self.isContinuous &&_datasourceImages.count > 1)) { 76 | [self performSelector:@selector(autoSwitchBannerView) withObject:nil afterDelay:self.autoPlayTimeInterval]; 77 | } 78 | } 79 | } 80 | 81 | - (void)initializeScrollView { 82 | _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))]; 83 | _scrollView.delegate = self; 84 | _scrollView.pagingEnabled = YES; 85 | _scrollView.showsHorizontalScrollIndicator = NO; 86 | _scrollView.showsVerticalScrollIndicator = NO; 87 | _scrollView.autoresizingMask = self.autoresizingMask; 88 | _scrollView.scrollsToTop = NO; 89 | [self addSubview:_scrollView]; 90 | } 91 | 92 | - (void)initializePageControl { 93 | CGRect pageControlFrame = CGRectMake(0, 0, CGRectGetWidth(_scrollView.frame), 30); 94 | _pageControl = [[UIPageControl alloc] initWithFrame:pageControlFrame]; 95 | _pageControl.center = CGPointMake(CGRectGetWidth(_scrollView.frame)*0.5, CGRectGetHeight(_scrollView.frame) - 12.); 96 | _pageControl.userInteractionEnabled = NO; 97 | [self addSubview:_pageControl]; 98 | } 99 | 100 | - (void)loadData { 101 | NSAssert(_datasource != nil, @"datasource must not nil"); 102 | _datasourceImages = [_datasource numberOfKDCycleBannerView:self]; 103 | 104 | if (_datasourceImages.count == 0) { 105 | //显示默认页,无数据页面 106 | if ([self.datasource respondsToSelector:@selector(placeHolderImageOfZeroBannerView)]) { 107 | UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(_scrollView.frame), CGRectGetHeight(_scrollView.frame))]; 108 | imageView.contentMode = UIViewContentModeScaleAspectFill; 109 | imageView.backgroundColor = [UIColor clearColor]; 110 | imageView.image = [self.datasource placeHolderImageOfZeroBannerView]; 111 | [_scrollView addSubview:imageView]; 112 | } 113 | return; 114 | } 115 | 116 | _pageControl.numberOfPages = _datasourceImages.count; 117 | _pageControl.currentPage = 0; 118 | 119 | if (self.isContinuous) { 120 | NSMutableArray *cycleDatasource = [_datasourceImages mutableCopy]; 121 | [cycleDatasource insertObject:[_datasourceImages lastObject] atIndex:0]; 122 | [cycleDatasource addObject:[_datasourceImages firstObject]]; 123 | _datasourceImages = [cycleDatasource copy]; 124 | } 125 | 126 | CGFloat contentWidth = CGRectGetWidth(_scrollView.frame); 127 | CGFloat contentHeight = CGRectGetHeight(_scrollView.frame); 128 | 129 | _scrollView.contentSize = CGSizeMake(contentWidth * _datasourceImages.count, contentHeight); 130 | 131 | for (NSInteger i = 0; i < _datasourceImages.count; i++) { 132 | CGRect imgRect = CGRectMake(contentWidth * i, 0, contentWidth, contentHeight); 133 | UIImageView *imageView = [[UIImageView alloc] initWithFrame:imgRect]; 134 | imageView.backgroundColor = [UIColor clearColor]; 135 | imageView.contentMode = [_datasource contentModeForImageIndex:i]; 136 | 137 | id imageSource = [_datasourceImages objectAtIndex:i]; 138 | if ([imageSource isKindOfClass:[UIImage class]]) { 139 | imageView.image = imageSource; 140 | }else if ([imageSource isKindOfClass:[NSString class]] || [imageSource isKindOfClass:[NSURL class]]) { 141 | UIActivityIndicatorView *activityIndicatorView = [UIActivityIndicatorView new]; 142 | activityIndicatorView.center = CGPointMake(CGRectGetWidth(_scrollView.frame) * 0.5, CGRectGetHeight(_scrollView.frame) * 0.5); 143 | activityIndicatorView.tag = 100; 144 | activityIndicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; 145 | [activityIndicatorView startAnimating]; 146 | [imageView addSubview:activityIndicatorView]; 147 | [imageView addObserver:self forKeyPath:@"image" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:kContentImageViewObservationContext]; 148 | 149 | if ([self.datasource respondsToSelector:@selector(placeHolderImageOfBannerView:atIndex:)]) { 150 | UIImage *placeHolderImage = [self.datasource placeHolderImageOfBannerView:self atIndex:i]; 151 | NSAssert(placeHolderImage != nil, @"placeHolderImage must not be nil"); 152 | [imageView sd_setImageWithURL:[imageSource isKindOfClass:[NSString class]] ? [NSURL URLWithString:imageSource] : imageSource placeholderImage:placeHolderImage]; 153 | }else { 154 | [imageView sd_setImageWithURL:[imageSource isKindOfClass:[NSString class]] ? [NSURL URLWithString:imageSource] : imageSource]; 155 | } 156 | 157 | } 158 | [_scrollView addSubview:imageView]; 159 | } 160 | 161 | if (self.isContinuous && _datasourceImages.count > 1) { 162 | _scrollView.contentOffset = CGPointMake(CGRectGetWidth(_scrollView.frame), 0); 163 | } 164 | 165 | // single tap gesture recognizer 166 | UITapGestureRecognizer *tapGestureRecognize = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureRecognizer:)]; 167 | tapGestureRecognize.delegate = self; 168 | tapGestureRecognize.numberOfTapsRequired = 1; 169 | [_scrollView addGestureRecognizer:tapGestureRecognize]; 170 | 171 | } 172 | 173 | - (void)reloadDataWithCompleteBlock:(CompleteBlock)competeBlock { 174 | self.completeBlock = competeBlock; 175 | [self setNeedsLayout]; 176 | } 177 | 178 | - (void)moveToTargetPosition:(CGFloat)targetX withAnimated:(BOOL)animated { 179 | [_scrollView setContentOffset:CGPointMake(targetX, 0) animated:animated]; 180 | } 181 | 182 | - (void)setCurrentPage:(NSInteger)currentPage animated:(BOOL)animated { 183 | NSInteger page = MIN(_datasourceImages.count - 1, MAX(0, currentPage)); 184 | 185 | [self setSwitchPage:page animated:animated withUserInterface:YES]; 186 | } 187 | 188 | - (void)setSwitchPage:(NSInteger)switchPage animated:(BOOL)animated withUserInterface:(BOOL)userInterface { 189 | 190 | NSInteger page = -1; 191 | 192 | if (userInterface) { 193 | page = switchPage; 194 | }else { 195 | _currentSelectedPage++; 196 | page = _currentSelectedPage % (self.isContinuous ? (_datasourceImages.count - 1) : _datasourceImages.count); 197 | } 198 | 199 | if (self.isContinuous) { 200 | if (_datasourceImages.count > 1) { 201 | if (page >= (_datasourceImages.count -2)) { 202 | page = _datasourceImages.count - 3; 203 | _currentSelectedPage = 0; 204 | [self moveToTargetPosition:CGRectGetWidth(_scrollView.frame) * (page + 2) withAnimated:animated]; 205 | }else { 206 | [self moveToTargetPosition:CGRectGetWidth(_scrollView.frame) * (page + 1) withAnimated:animated]; 207 | } 208 | }else { 209 | [self moveToTargetPosition:0 withAnimated:animated]; 210 | } 211 | }else { 212 | [self moveToTargetPosition:CGRectGetWidth(_scrollView.frame) * page withAnimated:animated]; 213 | } 214 | 215 | [self scrollViewDidScroll:_scrollView]; 216 | } 217 | 218 | - (void)autoSwitchBannerView { 219 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(autoSwitchBannerView) object:nil]; 220 | 221 | [self setSwitchPage:-1 animated:YES withUserInterface:NO]; 222 | 223 | [self performSelector:_cmd withObject:nil afterDelay:self.autoPlayTimeInterval]; 224 | } 225 | 226 | #pragma mark - KVO 227 | 228 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 229 | if (context == kContentImageViewObservationContext) { 230 | UIImageView *imageView = (UIImageView *)object; 231 | UIActivityIndicatorView *activityIndicatorView = (UIActivityIndicatorView *)[imageView viewWithTag:100]; 232 | [activityIndicatorView removeFromSuperview]; 233 | [imageView removeObserver:self forKeyPath:@"image"]; 234 | } 235 | } 236 | 237 | #pragma mark - UIScrollViewDelegate 238 | 239 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 240 | CGFloat targetX = scrollView.contentOffset.x; 241 | 242 | CGFloat item_width = CGRectGetWidth(scrollView.frame); 243 | 244 | if (self.isContinuous && _datasourceImages.count >= 3) { 245 | if (targetX >= item_width * (_datasourceImages.count - 1)) { 246 | targetX = item_width; 247 | _scrollView.contentOffset = CGPointMake(targetX, 0); 248 | }else if (targetX <= 0) { 249 | targetX = item_width * (_datasourceImages.count - 2); 250 | _scrollView.contentOffset = CGPointMake(targetX, 0); 251 | } 252 | } 253 | 254 | NSInteger page = (scrollView.contentOffset.x + item_width * 0.5) / item_width; 255 | 256 | if (self.isContinuous && _datasourceImages.count > 1) { 257 | page--; 258 | if (page >= _pageControl.numberOfPages) { 259 | page = 0; 260 | }else if (page < 0) { 261 | page = _pageControl.numberOfPages - 1; 262 | } 263 | } 264 | 265 | _currentSelectedPage = page; 266 | 267 | if (page != _pageControl.currentPage) { 268 | if ([self.delegate respondsToSelector:@selector(cycleBannerView:didScrollToIndex:)]) { 269 | [self.delegate cycleBannerView:self didScrollToIndex:page]; 270 | } 271 | } 272 | 273 | _pageControl.currentPage = page; 274 | } 275 | 276 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 277 | { 278 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(autoSwitchBannerView) object:nil]; 279 | } 280 | 281 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 282 | { 283 | [self performSelector:@selector(autoSwitchBannerView) withObject:nil afterDelay:self.autoPlayTimeInterval]; 284 | } 285 | 286 | #pragma mark - UIGestureRecognizerDelegate 287 | 288 | #pragma mark - UITapGestureRecognizerSelector 289 | 290 | - (void)singleTapGestureRecognizer:(UITapGestureRecognizer *)tapGesture { 291 | 292 | NSInteger page = (NSInteger)(_scrollView.contentOffset.x / CGRectGetWidth(_scrollView.frame)); 293 | 294 | if ([self.delegate respondsToSelector:@selector(cycleBannerView:didSelectedAtIndex:)]) { 295 | [self.delegate cycleBannerView:self didSelectedAtIndex:self.isContinuous ? --page : page]; 296 | } 297 | } 298 | 299 | @end 300 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIButton+WebCache.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 "UIButton+WebCache.h" 10 | #import "objc/runtime.h" 11 | #import "UIView+WebCacheOperation.h" 12 | 13 | static char imageURLStorageKey; 14 | 15 | @implementation UIButton (WebCache) 16 | 17 | - (NSURL *)sd_currentImageURL { 18 | NSURL *url = self.imageURLStorage[@(self.state)]; 19 | 20 | if (!url) { 21 | url = self.imageURLStorage[@(UIControlStateNormal)]; 22 | } 23 | 24 | return url; 25 | } 26 | 27 | - (NSURL *)sd_imageURLForState:(UIControlState)state { 28 | return self.imageURLStorage[@(state)]; 29 | } 30 | 31 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state { 32 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 33 | } 34 | 35 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { 36 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 37 | } 38 | 39 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 40 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 41 | } 42 | 43 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { 44 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; 45 | } 46 | 47 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { 48 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; 49 | } 50 | 51 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 52 | 53 | [self setImage:placeholder forState:state]; 54 | [self sd_cancelImageLoadForState:state]; 55 | 56 | if (!url) { 57 | [self.imageURLStorage removeObjectForKey:@(state)]; 58 | 59 | dispatch_main_async_safe(^{ 60 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 61 | if (completedBlock) { 62 | completedBlock(nil, error, SDImageCacheTypeNone, url); 63 | } 64 | }); 65 | 66 | return; 67 | } 68 | 69 | self.imageURLStorage[@(state)] = url; 70 | 71 | __weak UIButton *wself = self; 72 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 73 | if (!wself) return; 74 | dispatch_main_sync_safe(^{ 75 | __strong UIButton *sself = wself; 76 | if (!sself) return; 77 | if (image) { 78 | [sself setImage:image forState:state]; 79 | } 80 | if (completedBlock && finished) { 81 | completedBlock(image, error, cacheType, url); 82 | } 83 | }); 84 | }]; 85 | [self sd_setImageLoadOperation:operation forState:state]; 86 | } 87 | 88 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { 89 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 90 | } 91 | 92 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { 93 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 94 | } 95 | 96 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 97 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 98 | } 99 | 100 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { 101 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; 102 | } 103 | 104 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { 105 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; 106 | } 107 | 108 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 109 | [self sd_cancelImageLoadForState:state]; 110 | 111 | [self setBackgroundImage:placeholder forState:state]; 112 | 113 | if (url) { 114 | __weak UIButton *wself = self; 115 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 116 | if (!wself) return; 117 | dispatch_main_sync_safe(^{ 118 | __strong UIButton *sself = wself; 119 | if (!sself) return; 120 | if (image) { 121 | [sself setBackgroundImage:image forState:state]; 122 | } 123 | if (completedBlock && finished) { 124 | completedBlock(image, error, cacheType, url); 125 | } 126 | }); 127 | }]; 128 | [self sd_setBackgroundImageLoadOperation:operation forState:state]; 129 | } else { 130 | dispatch_main_async_safe(^{ 131 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 132 | if (completedBlock) { 133 | completedBlock(nil, error, SDImageCacheTypeNone, url); 134 | } 135 | }); 136 | } 137 | } 138 | 139 | - (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state { 140 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; 141 | } 142 | 143 | - (void)sd_cancelImageLoadForState:(UIControlState)state { 144 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; 145 | } 146 | 147 | - (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state { 148 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; 149 | } 150 | 151 | - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state { 152 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; 153 | } 154 | 155 | - (NSMutableDictionary *)imageURLStorage { 156 | NSMutableDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey); 157 | if (!storage) 158 | { 159 | storage = [NSMutableDictionary dictionary]; 160 | objc_setAssociatedObject(self, &imageURLStorageKey, storage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 161 | } 162 | 163 | return storage; 164 | } 165 | 166 | @end 167 | 168 | 169 | @implementation UIButton (WebCacheDeprecated) 170 | 171 | - (NSURL *)currentImageURL { 172 | return [self sd_currentImageURL]; 173 | } 174 | 175 | - (NSURL *)imageURLForState:(UIControlState)state { 176 | return [self sd_imageURLForState:state]; 177 | } 178 | 179 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state { 180 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 181 | } 182 | 183 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { 184 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 185 | } 186 | 187 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 188 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 189 | } 190 | 191 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { 192 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 193 | if (completedBlock) { 194 | completedBlock(image, error, cacheType); 195 | } 196 | }]; 197 | } 198 | 199 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { 200 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 201 | if (completedBlock) { 202 | completedBlock(image, error, cacheType); 203 | } 204 | }]; 205 | } 206 | 207 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 208 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 209 | if (completedBlock) { 210 | completedBlock(image, error, cacheType); 211 | } 212 | }]; 213 | } 214 | 215 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { 216 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 217 | } 218 | 219 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { 220 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 221 | } 222 | 223 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 224 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 225 | } 226 | 227 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { 228 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 229 | if (completedBlock) { 230 | completedBlock(image, error, cacheType); 231 | } 232 | }]; 233 | } 234 | 235 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { 236 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 237 | if (completedBlock) { 238 | completedBlock(image, error, cacheType); 239 | } 240 | }]; 241 | } 242 | 243 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 244 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 245 | if (completedBlock) { 246 | completedBlock(image, error, cacheType); 247 | } 248 | }]; 249 | } 250 | 251 | - (void)cancelCurrentImageLoad { 252 | // in a backwards compatible manner, cancel for current state 253 | [self sd_cancelImageLoadForState:self.state]; 254 | } 255 | 256 | - (void)cancelBackgroundImageLoadForState:(UIControlState)state { 257 | [self sd_cancelBackgroundImageLoadForState:state]; 258 | } 259 | 260 | @end 261 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/README.md: -------------------------------------------------------------------------------- 1 | Web Image 2 | ========= 3 | [![Build Status](http://img.shields.io/travis/rs/SDWebImage/master.svg?style=flat)](https://travis-ci.org/rs/SDWebImage) 4 | [![Pod Version](http://img.shields.io/cocoapods/v/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) 5 | [![Pod Platform](http://img.shields.io/cocoapods/p/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) 6 | [![Pod License](http://img.shields.io/cocoapods/l/SDWebImage.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html) 7 | 8 | This library provides a category for UIImageView with support for remote images coming from the web. 9 | 10 | It provides: 11 | 12 | - An UIImageView category adding web image and cache management to the Cocoa Touch framework 13 | - An asynchronous image downloader 14 | - An asynchronous memory + disk image caching with automatic cache expiration handling 15 | - Animated GIF support 16 | - WebP format support 17 | - A background image decompression 18 | - A guarantee that the same URL won't be downloaded several times 19 | - A guarantee that bogus URLs won't be retried again and again 20 | - A guarantee that main thread will never be blocked 21 | - Performances! 22 | - Use GCD and ARC 23 | - Arm64 support 24 | 25 | NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.1.1 26 | minimum deployement version. If you need iOS < 5.0 support, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat). 27 | 28 | [How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F) 29 | 30 | Who Use It 31 | ---------- 32 | 33 | Find out [who uses SDWebImage](https://github.com/rs/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list. 34 | 35 | How To Use 36 | ---------- 37 | 38 | API documentation is available at [http://hackemist.com/SDWebImage/doc/](http://hackemist.com/SDWebImage/doc/) 39 | 40 | ### Using UIImageView+WebCache category with UITableView 41 | 42 | Just #import the UIImageView+WebCache.h header, and call the setImageWithURL:placeholderImage: 43 | method from the tableView:cellForRowAtIndexPath: UITableViewDataSource method. Everything will be 44 | handled for you, from async downloads to caching management. 45 | 46 | ```objective-c 47 | #import 48 | 49 | ... 50 | 51 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 52 | { 53 | static NSString *MyIdentifier = @"MyIdentifier"; 54 | 55 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 56 | 57 | if (cell == nil) 58 | { 59 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 60 | reuseIdentifier:MyIdentifier] autorelease]; 61 | } 62 | 63 | // Here we use the new provided setImageWithURL: method to load the web image 64 | [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] 65 | placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; 66 | 67 | cell.textLabel.text = @"My Text"; 68 | return cell; 69 | } 70 | ``` 71 | 72 | ### Using blocks 73 | 74 | With blocks, you can be notified about the image download progress and whenever the image retrival 75 | has completed with success or not: 76 | 77 | ```objective-c 78 | // Here we use the new provided setImageWithURL: method to load the web image 79 | [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] 80 | placeholderImage:[UIImage imageNamed:@"placeholder.png"] 81 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {... completion code here ...}]; 82 | ``` 83 | 84 | Note: neither your success nor failure block will be call if your image request is canceled before completion. 85 | 86 | ### Using SDWebImageManager 87 | 88 | The SDWebImageManager is the class behind the UIImageView+WebCache category. It ties the 89 | asynchronous downloader with the image cache store. You can use this class directly to benefit 90 | from web image downloading with caching in another context than a UIView (ie: with Cocoa). 91 | 92 | Here is a simple example of how to use SDWebImageManager: 93 | 94 | ```objective-c 95 | SDWebImageManager *manager = [SDWebImageManager sharedManager]; 96 | [manager downloadWithURL:imageURL 97 | options:0 98 | progress:^(NSInteger receivedSize, NSInteger expectedSize) 99 | { 100 | // progression tracking code 101 | } 102 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) 103 | { 104 | if (image) 105 | { 106 | // do something with image 107 | } 108 | }]; 109 | ``` 110 | 111 | ### Using Asynchronous Image Downloader Independently 112 | 113 | It's also possible to use the async image downloader independently: 114 | 115 | ```objective-c 116 | [SDWebImageDownloader.sharedDownloader downloadImageWithURL:imageURL 117 | options:0 118 | progress:^(NSInteger receivedSize, NSInteger expectedSize) 119 | { 120 | // progression tracking code 121 | } 122 | completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) 123 | { 124 | if (image && finished) 125 | { 126 | // do something with image 127 | } 128 | }]; 129 | ``` 130 | 131 | ### Using Asynchronous Image Caching Independently 132 | 133 | It is also possible to use the aync based image cache store independently. SDImageCache 134 | maintains a memory cache and an optional disk cache. Disk cache write operations are performed 135 | asynchronous so it doesn't add unnecessary latency to the UI. 136 | 137 | The SDImageCache class provides a singleton instance for convenience but you can create your own 138 | instance if you want to create separated cache namespace. 139 | 140 | To lookup the cache, you use the `queryDiskCacheForKey:done:` method. If the method returns nil, it means the cache 141 | doesn't currently own the image. You are thus responsible for generating and caching it. The cache 142 | key is an application unique identifier for the image to cache. It is generally the absolute URL of 143 | the image. 144 | 145 | ```objective-c 146 | SDImageCache *imageCache = [[SDImageCache alloc] initWithNamespace:@"myNamespace"]; 147 | [imageCache queryDiskCacheForKey:myCacheKey done:^(UIImage *image) 148 | { 149 | // image is not nil if image was found 150 | }]; 151 | ``` 152 | 153 | By default SDImageCache will lookup the disk cache if an image can't be found in the memory cache. 154 | You can prevent this from happening by calling the alternative method `imageFromMemoryCacheForKey:`. 155 | 156 | To store an image into the cache, you use the storeImage:forKey: method: 157 | 158 | ```objective-c 159 | [[SDImageCache sharedImageCache] storeImage:myImage forKey:myCacheKey]; 160 | ``` 161 | 162 | By default, the image will be stored in memory cache as well as on disk cache (asynchronously). If 163 | you want only the memory cache, use the alternative method storeImage:forKey:toDisk: with a negative 164 | third argument. 165 | 166 | ### Using cache key filter 167 | 168 | Sometime, you may not want to use the image URL as cache key because part of the URL is dynamic 169 | (i.e.: for access control purpose). SDWebImageManager provides a way to set a cache key filter that 170 | takes the NSURL as input, and output a cache key NSString. 171 | 172 | The following example sets a filter in the application delegate that will remove any query-string from 173 | the URL before to use it as a cache key: 174 | 175 | ```objective-c 176 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 177 | { 178 | SDWebImageManager.sharedManager.cacheKeyFilter:^(NSURL *url) 179 | { 180 | url = [[[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path] autorelease]; 181 | return [url absoluteString]; 182 | }; 183 | 184 | // Your app init code... 185 | return YES; 186 | } 187 | ``` 188 | 189 | 190 | Common Problems 191 | --------------- 192 | 193 | ### Using dynamic image size with UITableViewCell 194 | 195 | UITableView determins the size of the image by the first image set for a cell. If your remote images 196 | don't have the same size as your placeholder image, you may experience strange anamorphic scaling issue. 197 | The following article gives a way to workaround this issue: 198 | 199 | [http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/](http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/) 200 | 201 | 202 | ### Handle image refresh 203 | 204 | SDWebImage does very aggressive caching by default. It ignores all kind of caching control header returned by the HTTP server and cache the returned images with no time restriction. It implies your images URLs are static URLs pointing to images that never change. If the pointed image happen to change, some parts of the URL should change accordingly. 205 | 206 | If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the `SDWebImageRefreshCached` flag. This will slightly degrade the performance but will respect the HTTP caching control headers: 207 | 208 | ``` objective-c 209 | [imageView setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"] 210 | placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"] 211 | options:SDWebImageRefreshCached]; 212 | ``` 213 | 214 | ### Add a progress indicator 215 | 216 | See this category: https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage 217 | 218 | Installation 219 | ------------ 220 | 221 | There are three ways to use SDWebImage in your project: 222 | - using Cocoapods 223 | - copying all the files into your project 224 | - importing the project as a static library 225 | 226 | ### Installation with CocoaPods 227 | 228 | [CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the [Get Started](http://cocoapods.org/#get_started) section for more details. 229 | 230 | #### Podfile 231 | ``` 232 | platform :ios, '6.1' 233 | pod 'SDWebImage', '~>3.6' 234 | ``` 235 | 236 | ### Add the SDWebImage project to your project 237 | 238 | - Download and unzip the last version of the framework from the [download page](https://github.com/rs/SDWebImage/releases) 239 | - Right-click on the project navigator and select "Add Files to "Your Project": 240 | - In the dialog, select SDWebImage.framework: 241 | - Check the "Copy items into destination group's folder (if needed)" checkbox 242 | 243 | ### Add dependencies 244 | 245 | - In you application project app’s target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block: 246 | - Click the "+" button again and select the "ImageIO.framework", this is needed by the progressive download feature: 247 | 248 | ### Add Linker Flag 249 | 250 | Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag: 251 | 252 | ![Other Linker Flags](http://dl.dropbox.com/u/123346/SDWebImage/10_other_linker_flags.jpg) 253 | 254 | Alternatively, if this causes compilation problems with frameworks that extend optional libraries, such as Parse, RestKit or opencv2, instead of the -ObjC flag use: 255 | 256 | ``` 257 | -force_load SDWebImage.framework/Versions/Current/SDWebImage 258 | ``` 259 | 260 | ### Import headers in your source files 261 | 262 | In the source files where you need to use the library, import the header file: 263 | 264 | ```objective-c 265 | #import 266 | ``` 267 | 268 | ### Build Project 269 | 270 | At this point your workspace should build without error. If you are having problem, post to the Issue and the 271 | community can help you solve it. 272 | 273 | Future Enhancements 274 | ------------------- 275 | 276 | - LRU memory cache cleanup instead of reset on memory warning 277 | 278 | ## Licenses 279 | 280 | All source code is licensed under the [MIT License](https://raw.github.com/rs/SDWebImage/master/LICENSE). 281 | -------------------------------------------------------------------------------- /KDCycleBannerViewDemo/Pods/SDWebImage/SDWebImage/UIButton+WebCache.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 "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with UIButtonView. 14 | */ 15 | @interface UIButton (WebCache) 16 | 17 | /** 18 | * Get the current image URL. 19 | */ 20 | - (NSURL *)sd_currentImageURL; 21 | 22 | /** 23 | * Get the image URL for a control state. 24 | * 25 | * @param state Which state you want to know the URL for. The values are described in UIControlState. 26 | */ 27 | - (NSURL *)sd_imageURLForState:(UIControlState)state; 28 | 29 | /** 30 | * Set the imageView `image` with an `url`. 31 | * 32 | * The download is asynchronous and cached. 33 | * 34 | * @param url The url for the image. 35 | * @param state The state that uses the specified title. The values are described in UIControlState. 36 | */ 37 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state; 38 | 39 | /** 40 | * Set the imageView `image` with an `url` and a placeholder. 41 | * 42 | * The download is asynchronous and cached. 43 | * 44 | * @param url The url for the image. 45 | * @param state The state that uses the specified title. The values are described in UIControlState. 46 | * @param placeholder The image to be set initially, until the image request finishes. 47 | * @see sd_setImageWithURL:placeholderImage:options: 48 | */ 49 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; 50 | 51 | /** 52 | * Set the imageView `image` with an `url`, placeholder and custom options. 53 | * 54 | * The download is asynchronous and cached. 55 | * 56 | * @param url The url for the image. 57 | * @param state The state that uses the specified title. The values are described in UIControlState. 58 | * @param placeholder The image to be set initially, until the image request finishes. 59 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 60 | */ 61 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 62 | 63 | /** 64 | * Set the imageView `image` with an `url`. 65 | * 66 | * The download is asynchronous and cached. 67 | * 68 | * @param url The url for the image. 69 | * @param state The state that uses the specified title. The values are described in UIControlState. 70 | * @param completedBlock A block called when operation has been completed. This block has no return value 71 | * and takes the requested UIImage as first parameter. In case of error the image parameter 72 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 73 | * indicating if the image was retrived from the local cache of from the network. 74 | * The forth parameter is the original image url. 75 | */ 76 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock; 77 | 78 | /** 79 | * Set the imageView `image` with an `url`, placeholder. 80 | * 81 | * The download is asynchronous and cached. 82 | * 83 | * @param url The url for the image. 84 | * @param state The state that uses the specified title. The values are described in UIControlState. 85 | * @param placeholder The image to be set initially, until the image request finishes. 86 | * @param completedBlock A block called when operation has been completed. This block has no return value 87 | * and takes the requested UIImage as first parameter. In case of error the image parameter 88 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 89 | * indicating if the image was retrived from the local cache of from the network. 90 | * The forth parameter is the original image url. 91 | */ 92 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; 93 | 94 | /** 95 | * Set the imageView `image` with an `url`, placeholder and custom options. 96 | * 97 | * The download is asynchronous and cached. 98 | * 99 | * @param url The url for the image. 100 | * @param state The state that uses the specified title. The values are described in UIControlState. 101 | * @param placeholder The image to be set initially, until the image request finishes. 102 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 103 | * @param completedBlock A block called when operation has been completed. This block has no return value 104 | * and takes the requested UIImage as first parameter. In case of error the image parameter 105 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 106 | * indicating if the image was retrived from the local cache of from the network. 107 | * The forth parameter is the original image url. 108 | */ 109 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 110 | 111 | /** 112 | * Set the backgroundImageView `image` with an `url`. 113 | * 114 | * The download is asynchronous and cached. 115 | * 116 | * @param url The url for the image. 117 | * @param state The state that uses the specified title. The values are described in UIControlState. 118 | */ 119 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state; 120 | 121 | /** 122 | * Set the backgroundImageView `image` with an `url` and a placeholder. 123 | * 124 | * The download is asynchronous and cached. 125 | * 126 | * @param url The url for the image. 127 | * @param state The state that uses the specified title. The values are described in UIControlState. 128 | * @param placeholder The image to be set initially, until the image request finishes. 129 | * @see sd_setImageWithURL:placeholderImage:options: 130 | */ 131 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; 132 | 133 | /** 134 | * Set the backgroundImageView `image` with an `url`, placeholder and custom options. 135 | * 136 | * The download is asynchronous and cached. 137 | * 138 | * @param url The url for the image. 139 | * @param state The state that uses the specified title. The values are described in UIControlState. 140 | * @param placeholder The image to be set initially, until the image request finishes. 141 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 142 | */ 143 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 144 | 145 | /** 146 | * Set the backgroundImageView `image` with an `url`. 147 | * 148 | * The download is asynchronous and cached. 149 | * 150 | * @param url The url for the image. 151 | * @param state The state that uses the specified title. The values are described in UIControlState. 152 | * @param completedBlock A block called when operation has been completed. This block has no return value 153 | * and takes the requested UIImage as first parameter. In case of error the image parameter 154 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 155 | * indicating if the image was retrived from the local cache of from the network. 156 | * The forth parameter is the original image url. 157 | */ 158 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock; 159 | 160 | /** 161 | * Set the backgroundImageView `image` with an `url`, placeholder. 162 | * 163 | * The download is asynchronous and cached. 164 | * 165 | * @param url The url for the image. 166 | * @param state The state that uses the specified title. The values are described in UIControlState. 167 | * @param placeholder The image to be set initially, until the image request finishes. 168 | * @param completedBlock A block called when operation has been completed. This block has no return value 169 | * and takes the requested UIImage as first parameter. In case of error the image parameter 170 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 171 | * indicating if the image was retrived from the local cache of from the network. 172 | * The forth parameter is the original image url. 173 | */ 174 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; 175 | 176 | /** 177 | * Set the backgroundImageView `image` with an `url`, placeholder and custom options. 178 | * 179 | * The download is asynchronous and cached. 180 | * 181 | * @param url The url for the image. 182 | * @param placeholder The image to be set initially, until the image request finishes. 183 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 184 | * @param completedBlock A block called when operation has been completed. This block has no return value 185 | * and takes the requested UIImage as first parameter. In case of error the image parameter 186 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 187 | * indicating if the image was retrived from the local cache of from the network. 188 | * The forth parameter is the original image url. 189 | */ 190 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 191 | 192 | /** 193 | * Cancel the current image download 194 | */ 195 | - (void)sd_cancelImageLoadForState:(UIControlState)state; 196 | 197 | /** 198 | * Cancel the current backgroundImage download 199 | */ 200 | - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state; 201 | 202 | @end 203 | 204 | 205 | @interface UIButton (WebCacheDeprecated) 206 | 207 | - (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`"); 208 | - (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`"); 209 | 210 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`"); 211 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`"); 212 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:`"); 213 | 214 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:completed:`"); 215 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:completed:`"); 216 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:completed:`"); 217 | 218 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:`"); 219 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:`"); 220 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:`"); 221 | 222 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:completed:`"); 223 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`"); 224 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:`"); 225 | 226 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelImageLoadForState:`"); 227 | - (void)cancelBackgroundImageLoadForState:(UIControlState)state __deprecated_msg("Use `sd_cancelBackgroundImageLoadForState:`"); 228 | 229 | @end 230 | --------------------------------------------------------------------------------