├── README.md └── Tool └── demo ├── Podfile.lock ├── Pods ├── Manifest.lock ├── Masonry │ ├── LICENSE │ ├── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── MASConstraintMaker.m │ │ ├── MASLayoutConstraint.h │ │ ├── MASLayoutConstraint.m │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewConstraint.h │ │ ├── MASViewConstraint.m │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASAdditions.m │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── View+MASAdditions.h │ │ ├── View+MASAdditions.m │ │ ├── View+MASShorthandAdditions.h │ │ ├── ViewController+MASAdditions.h │ │ └── ViewController+MASAdditions.m │ └── README.md ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ ├── jackson.xcuserdatad │ │ └── xcschemes │ │ │ ├── Masonry.xcscheme │ │ │ ├── Pods-Tool.xcscheme │ │ │ ├── SDWebImage.xcscheme │ │ │ └── xcschememanagement.plist │ │ └── yezhan.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── SDWebImage │ ├── LICENSE │ ├── README.md │ └── SDWebImage │ │ ├── NSButton+WebCache.h │ │ ├── NSButton+WebCache.m │ │ ├── NSData+ImageContentType.h │ │ ├── NSData+ImageContentType.m │ │ ├── NSImage+WebCache.h │ │ ├── NSImage+WebCache.m │ │ ├── SDAnimatedImageRep.h │ │ ├── SDAnimatedImageRep.m │ │ ├── SDImageCache.h │ │ ├── SDImageCache.m │ │ ├── SDImageCacheConfig.h │ │ ├── SDImageCacheConfig.m │ │ ├── SDWebImageCoder.h │ │ ├── SDWebImageCoder.m │ │ ├── SDWebImageCoderHelper.h │ │ ├── SDWebImageCoderHelper.m │ │ ├── SDWebImageCodersManager.h │ │ ├── SDWebImageCodersManager.m │ │ ├── SDWebImageCompat.h │ │ ├── SDWebImageCompat.m │ │ ├── SDWebImageDownloader.h │ │ ├── SDWebImageDownloader.m │ │ ├── SDWebImageDownloaderOperation.h │ │ ├── SDWebImageDownloaderOperation.m │ │ ├── SDWebImageFrame.h │ │ ├── SDWebImageFrame.m │ │ ├── SDWebImageGIFCoder.h │ │ ├── SDWebImageGIFCoder.m │ │ ├── SDWebImageImageIOCoder.h │ │ ├── SDWebImageImageIOCoder.m │ │ ├── SDWebImageManager.h │ │ ├── SDWebImageManager.m │ │ ├── SDWebImageOperation.h │ │ ├── SDWebImagePrefetcher.h │ │ ├── SDWebImagePrefetcher.m │ │ ├── SDWebImageTransition.h │ │ ├── SDWebImageTransition.m │ │ ├── UIButton+WebCache.h │ │ ├── UIButton+WebCache.m │ │ ├── UIImage+ForceDecode.h │ │ ├── UIImage+ForceDecode.m │ │ ├── UIImage+GIF.h │ │ ├── UIImage+GIF.m │ │ ├── UIImage+MultiFormat.h │ │ ├── UIImage+MultiFormat.m │ │ ├── UIImageView+HighlightedWebCache.h │ │ ├── UIImageView+HighlightedWebCache.m │ │ ├── UIImageView+WebCache.h │ │ ├── UIImageView+WebCache.m │ │ ├── UIView+WebCache.h │ │ ├── UIView+WebCache.m │ │ ├── UIView+WebCacheOperation.h │ │ └── UIView+WebCacheOperation.m └── Target Support Files │ ├── Masonry │ ├── Info.plist │ ├── Masonry-dummy.m │ ├── Masonry-prefix.pch │ ├── Masonry-umbrella.h │ ├── Masonry.modulemap │ └── Masonry.xcconfig │ ├── Pods-Tool │ ├── Info.plist │ ├── Pods-Tool-acknowledgements.markdown │ ├── Pods-Tool-acknowledgements.plist │ ├── Pods-Tool-dummy.m │ ├── Pods-Tool-frameworks.sh │ ├── Pods-Tool-resources.sh │ ├── Pods-Tool-umbrella.h │ ├── Pods-Tool.debug.xcconfig │ ├── Pods-Tool.modulemap │ └── Pods-Tool.release.xcconfig │ └── SDWebImage │ ├── Info.plist │ ├── SDWebImage-dummy.m │ ├── SDWebImage-prefix.pch │ ├── SDWebImage-umbrella.h │ ├── SDWebImage.modulemap │ └── SDWebImage.xcconfig ├── Tool.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── jackson.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── jackson.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── yezhan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── Tool.xcworkspace ├── contents.xcworkspacedata ├── xcshareddata │ └── IDEWorkspaceChecks.plist └── xcuserdata │ ├── jackson.xcuserdatad │ └── UserInterfaceState.xcuserstate │ └── yezhan.xcuserdatad │ ├── UserInterfaceState.xcuserstate │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── Tool ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── lady.imageset │ │ ├── 140-1F123155215.jpg │ │ └── Contents.json │ └── timg.imageset │ │ ├── Contents.json │ │ └── timg.jpg ├── Base.lproj │ └── LaunchScreen.storyboard ├── Info.plist ├── Main.storyboard ├── ViewController.h ├── ViewController.m ├── class │ ├── AvatarListView.h │ ├── AvatarListView.m │ ├── FHSegmentView.h │ ├── FHSegmentView.m │ ├── HFCircleImageView.h │ ├── HFCircleImageView.m │ ├── HFGradientButton.h │ ├── HFGradientButton.m │ ├── HFNumberTextField.h │ ├── HFNumberTextField.m │ ├── HFUIFactory.h │ ├── HFUIFactory.m │ ├── HTDateSelectedComponent.h │ ├── HTDateSelectedComponent.m │ ├── YZVerifyButton.h │ ├── YZVerifyButton.m │ ├── sheet │ │ ├── FHAlertAction.h │ │ ├── FHAlertAction.m │ │ ├── FHAlertHeaderView.h │ │ ├── FHAlertHeaderView.m │ │ ├── FHAlertSheetView.h │ │ └── FHAlertSheetView.m │ └── 图片裁剪 │ │ ├── FHClipImageViewController.h │ │ ├── FHClipImageViewController.m │ │ ├── MaskView.h │ │ └── MaskView.m └── main.m └── podfile /README.md: -------------------------------------------------------------------------------- 1 | # iOS_Tool 2 | 开发中用到的一些自定义的控件 3 | 4 | 1. HFNumberTextField : 用于数字键盘左下角多一个按钮,默认是完成,可自定义按钮响应和显示文字 5 | 2. AvatarListView : 用于头像列表展示 ,提供定义头像大小,边框,间距,覆盖方式,覆盖距离、 6 | 3. YZVerifyButton 定时按钮,验证码发送成功之后手动开启走定时 7 | 4. 圆角ImageView,可以自定义圆角度,XIB和代码都适用 8 | 5. FHSegmentView : 用于切换滑动视图控制器,高度自定义UI风格 9 | 10 | UI 11 | 12 | 6. 图片裁剪,自由比例(未完善) 13 | 7. 渐变色的button 14 | 8. HFUIFactory : UI工厂类,手写代码再也不用设置巨多属性了 15 | 16 | -------------------------------------------------------------------------------- /Tool/demo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.1.0) 3 | - SDWebImage (4.3.3): 4 | - SDWebImage/Core (= 4.3.3) 5 | - SDWebImage/Core (4.3.3) 6 | 7 | DEPENDENCIES: 8 | - Masonry 9 | - SDWebImage (~> 4.0) 10 | 11 | SPEC REPOS: 12 | https://github.com/CocoaPods/Specs.git: 13 | - Masonry 14 | - SDWebImage 15 | 16 | SPEC CHECKSUMS: 17 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 18 | SDWebImage: de4d90b5bff3571eae7bd16202b1f43135409fa5 19 | 20 | PODFILE CHECKSUM: f42ee54a36e1bf27727606aac58095dd7ad7224f 21 | 22 | COCOAPODS: 1.5.0 23 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.1.0) 3 | - SDWebImage (4.3.3): 4 | - SDWebImage/Core (= 4.3.3) 5 | - SDWebImage/Core (4.3.3) 6 | 7 | DEPENDENCIES: 8 | - Masonry 9 | - SDWebImage (~> 4.0) 10 | 11 | SPEC REPOS: 12 | https://github.com/CocoaPods/Specs.git: 13 | - Masonry 14 | - SDWebImage 15 | 16 | SPEC CHECKSUMS: 17 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 18 | SDWebImage: de4d90b5bff3571eae7bd16202b1f43135409fa5 19 | 20 | PODFILE CHECKSUM: f42ee54a36e1bf27727606aac58095dd7ad7224f 21 | 22 | COCOAPODS: 1.5.0 23 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 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 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all 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. -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setInset:(CGFloat)inset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.inset = inset; 135 | } 136 | } 137 | 138 | - (void)setOffset:(CGFloat)offset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.offset = offset; 141 | } 142 | } 143 | 144 | - (void)setSizeOffset:(CGSize)sizeOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.sizeOffset = sizeOffset; 147 | } 148 | } 149 | 150 | - (void)setCenterOffset:(CGPoint)centerOffset { 151 | for (MASConstraint *constraint in self.childConstraints) { 152 | constraint.centerOffset = centerOffset; 153 | } 154 | } 155 | 156 | #pragma mark - MASConstraint 157 | 158 | - (void)activate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint activate]; 161 | } 162 | } 163 | 164 | - (void)deactivate { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | [constraint deactivate]; 167 | } 168 | } 169 | 170 | - (void)install { 171 | for (MASConstraint *constraint in self.childConstraints) { 172 | constraint.updateExisting = self.updateExisting; 173 | [constraint install]; 174 | } 175 | } 176 | 177 | - (void)uninstall { 178 | for (MASConstraint *constraint in self.childConstraints) { 179 | [constraint uninstall]; 180 | } 181 | } 182 | 183 | @end 184 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintMaker.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 26 | 27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline, 28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline, 29 | 30 | #endif 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 33 | 34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 42 | 43 | #endif 44 | 45 | }; 46 | 47 | /** 48 | * Provides factory methods for creating MASConstraints. 49 | * Constraints are collected until they are ready to be installed 50 | * 51 | */ 52 | @interface MASConstraintMaker : NSObject 53 | 54 | /** 55 | * The following properties return a new MASViewConstraint 56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 57 | */ 58 | @property (nonatomic, strong, readonly) MASConstraint *left; 59 | @property (nonatomic, strong, readonly) MASConstraint *top; 60 | @property (nonatomic, strong, readonly) MASConstraint *right; 61 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 62 | @property (nonatomic, strong, readonly) MASConstraint *leading; 63 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 64 | @property (nonatomic, strong, readonly) MASConstraint *width; 65 | @property (nonatomic, strong, readonly) MASConstraint *height; 66 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 67 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 68 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 69 | 70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 71 | 72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline; 73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline; 74 | 75 | #endif 76 | 77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 78 | 79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 87 | 88 | #endif 89 | 90 | /** 91 | * Returns a block which creates a new MASCompositeConstraint with the first item set 92 | * to the makers associated view and children corresponding to the set bits in the 93 | * MASAttribute parameter. Combine multiple attributes via binary-or. 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *edges; 103 | 104 | /** 105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 106 | * which generates the appropriate MASViewConstraint children (width, height) 107 | * with the first item set to the makers associated view 108 | */ 109 | @property (nonatomic, strong, readonly) MASConstraint *size; 110 | 111 | /** 112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 113 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 114 | * with the first item set to the makers associated view 115 | */ 116 | @property (nonatomic, strong, readonly) MASConstraint *center; 117 | 118 | /** 119 | * Whether or not to check for an existing constraint instead of adding constraint 120 | */ 121 | @property (nonatomic, assign) BOOL updateExisting; 122 | 123 | /** 124 | * Whether or not to remove existing constraints prior to installing 125 | */ 126 | @property (nonatomic, assign) BOOL removeExisting; 127 | 128 | /** 129 | * initialises the maker with a default view 130 | * 131 | * @param view any MASConstraint are created with this view as the first item 132 | * 133 | * @return a new MASConstraintMaker 134 | */ 135 | - (id)initWithView:(MAS_VIEW *)view; 136 | 137 | /** 138 | * Calls install method on any MASConstraints which have been created by this maker 139 | * 140 | * @return an array of all the installed MASConstraints 141 | */ 142 | - (NSArray *)install; 143 | 144 | - (MASConstraint * (^)(dispatch_block_t))group; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 48 | @(NSLayoutAttributeFirstBaseline) : @"firstBaseline", 49 | @(NSLayoutAttributeLastBaseline) : @"lastBaseline", 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 54 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 55 | @(NSLayoutAttributeTopMargin) : @"topMargin", 56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 61 | #endif 62 | 63 | }; 64 | 65 | }); 66 | return descriptionMap; 67 | } 68 | 69 | 70 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 71 | static dispatch_once_t once; 72 | static NSDictionary *descriptionMap; 73 | dispatch_once(&once, ^{ 74 | #if TARGET_OS_IPHONE || TARGET_OS_TV 75 | descriptionMap = @{ 76 | @(MASLayoutPriorityDefaultHigh) : @"high", 77 | @(MASLayoutPriorityDefaultLow) : @"low", 78 | @(MASLayoutPriorityDefaultMedium) : @"medium", 79 | @(MASLayoutPriorityRequired) : @"required", 80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 81 | }; 82 | #elif TARGET_OS_MAC 83 | descriptionMap = @{ 84 | @(MASLayoutPriorityDefaultHigh) : @"high", 85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 86 | @(MASLayoutPriorityDefaultMedium) : @"medium", 87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 89 | @(MASLayoutPriorityDefaultLow) : @"low", 90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 91 | @(MASLayoutPriorityRequired) : @"required", 92 | }; 93 | #endif 94 | }); 95 | return descriptionMap; 96 | } 97 | 98 | #pragma mark - description override 99 | 100 | + (NSString *)descriptionForObject:(id)obj { 101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 103 | } 104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 105 | } 106 | 107 | - (NSString *)description { 108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 109 | 110 | [description appendString:[self.class descriptionForObject:self]]; 111 | 112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]]; 115 | } 116 | 117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]]; 118 | 119 | if (self.secondItem) { 120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 121 | } 122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]]; 124 | } 125 | 126 | if (self.multiplier != 1) { 127 | [description appendFormat:@" * %g", self.multiplier]; 128 | } 129 | 130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 131 | [description appendFormat:@" %g", self.constant]; 132 | } else { 133 | if (self.constant) { 134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 135 | } 136 | } 137 | 138 | if (self.priority != MASLayoutPriorityRequired) { 139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 140 | } 141 | 142 | [description appendString:@">"]; 143 | return description; 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline; 39 | 40 | #endif 41 | 42 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 43 | 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 52 | 53 | #endif 54 | 55 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 56 | 57 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 59 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 60 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 61 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 62 | 63 | #endif 64 | 65 | /** 66 | * a key to associate with this view 67 | */ 68 | @property (nonatomic, strong) id mas_key; 69 | 70 | /** 71 | * Finds the closest common superview between this view and another view 72 | * 73 | * @param view other view 74 | * 75 | * @return returns nil if common superview could not be found 76 | */ 77 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 78 | 79 | /** 80 | * Creates a MASConstraintMaker with the callee view. 81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 82 | * 83 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 84 | * 85 | * @return Array of created MASConstraints 86 | */ 87 | - (NSArray *)mas_makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 88 | 89 | /** 90 | * Creates a MASConstraintMaker with the callee view. 91 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 92 | * If an existing constraint exists then it will be updated instead. 93 | * 94 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 95 | * 96 | * @return Array of created/updated MASConstraints 97 | */ 98 | - (NSArray *)mas_updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 99 | 100 | /** 101 | * Creates a MASConstraintMaker with the callee view. 102 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 103 | * All constraints previously installed for the view will be removed. 104 | * 105 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 106 | * 107 | * @return Array of created/updated MASConstraints 108 | */ 109 | - (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline; 36 | 37 | #endif 38 | 39 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 40 | 41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 49 | 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 53 | 54 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 55 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 56 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 57 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | 59 | #endif 60 | 61 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 62 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 63 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 64 | 65 | @end 66 | 67 | #define MAS_ATTR_FORWARD(attr) \ 68 | - (MASViewAttribute *)attr { \ 69 | return [self mas_##attr]; \ 70 | } 71 | 72 | @implementation MAS_VIEW (MASShorthandAdditions) 73 | 74 | MAS_ATTR_FORWARD(top); 75 | MAS_ATTR_FORWARD(left); 76 | MAS_ATTR_FORWARD(bottom); 77 | MAS_ATTR_FORWARD(right); 78 | MAS_ATTR_FORWARD(leading); 79 | MAS_ATTR_FORWARD(trailing); 80 | MAS_ATTR_FORWARD(width); 81 | MAS_ATTR_FORWARD(height); 82 | MAS_ATTR_FORWARD(centerX); 83 | MAS_ATTR_FORWARD(centerY); 84 | MAS_ATTR_FORWARD(baseline); 85 | 86 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 87 | 88 | MAS_ATTR_FORWARD(firstBaseline); 89 | MAS_ATTR_FORWARD(lastBaseline); 90 | 91 | #endif 92 | 93 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 94 | 95 | MAS_ATTR_FORWARD(leftMargin); 96 | MAS_ATTR_FORWARD(rightMargin); 97 | MAS_ATTR_FORWARD(topMargin); 98 | MAS_ATTR_FORWARD(bottomMargin); 99 | MAS_ATTR_FORWARD(leadingMargin); 100 | MAS_ATTR_FORWARD(trailingMargin); 101 | MAS_ATTR_FORWARD(centerXWithinMargins); 102 | MAS_ATTR_FORWARD(centerYWithinMargins); 103 | 104 | #endif 105 | 106 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 107 | 108 | MAS_ATTR_FORWARD(safeAreaLayoutGuideTop); 109 | MAS_ATTR_FORWARD(safeAreaLayoutGuideBottom); 110 | MAS_ATTR_FORWARD(safeAreaLayoutGuideLeft); 111 | MAS_ATTR_FORWARD(safeAreaLayoutGuideRight); 112 | 113 | #endif 114 | 115 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 116 | return [self mas_attribute]; 117 | } 118 | 119 | - (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 120 | return [self mas_makeConstraints:block]; 121 | } 122 | 123 | - (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 124 | return [self mas_updateConstraints:block]; 125 | } 126 | 127 | - (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 128 | return [self mas_remakeConstraints:block]; 129 | } 130 | 131 | @end 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Masonry/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Pods.xcodeproj/xcuserdata/jackson.xcuserdatad/xcschemes/Masonry.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Pods.xcodeproj/xcuserdata/jackson.xcuserdatad/xcschemes/Pods-Tool.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 66 | 68 | 69 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Pods.xcodeproj/xcuserdata/jackson.xcuserdatad/xcschemes/SDWebImage.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Pods.xcodeproj/xcuserdata/jackson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Masonry.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | Pods-Tool.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | SDWebImage.xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 2 27 | 28 | 29 | SuppressBuildableAutocreation 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Pods.xcodeproj/xcuserdata/yezhan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Masonry.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | Pods-Tool.xcscheme 13 | 14 | orderHint 15 | 2 16 | 17 | SDWebImage.xcscheme 18 | 19 | orderHint 20 | 3 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2017 Olivier Poitrey rs@dailymotion.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Fabrice Aneche 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import 11 | #import "SDWebImageCompat.h" 12 | 13 | typedef NS_ENUM(NSInteger, SDImageFormat) { 14 | SDImageFormatUndefined = -1, 15 | SDImageFormatJPEG = 0, 16 | SDImageFormatPNG, 17 | SDImageFormatGIF, 18 | SDImageFormatTIFF, 19 | SDImageFormatWebP, 20 | SDImageFormatHEIC 21 | }; 22 | 23 | @interface NSData (ImageContentType) 24 | 25 | /** 26 | * Return image format 27 | * 28 | * @param data the input image data 29 | * 30 | * @return the image format as `SDImageFormat` (enum) 31 | */ 32 | + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data; 33 | 34 | /** 35 | Convert SDImageFormat to UTType 36 | 37 | @param format Format as SDImageFormat 38 | @return The UTType as CFStringRef 39 | */ 40 | + (nonnull CFStringRef)sd_UTTypeFromSDImageFormat:(SDImageFormat)format; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Fabrice Aneche 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import "NSData+ImageContentType.h" 11 | #if SD_MAC 12 | #import 13 | #else 14 | #import 15 | #endif 16 | 17 | // Currently Image/IO does not support WebP 18 | #define kSDUTTypeWebP ((__bridge CFStringRef)@"public.webp") 19 | // AVFileTypeHEIC is defined in AVFoundation via iOS 11, we use this without import AVFoundation 20 | #define kSDUTTypeHEIC ((__bridge CFStringRef)@"public.heic") 21 | 22 | @implementation NSData (ImageContentType) 23 | 24 | + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data { 25 | if (!data) { 26 | return SDImageFormatUndefined; 27 | } 28 | 29 | // File signatures table: http://www.garykessler.net/library/file_sigs.html 30 | uint8_t c; 31 | [data getBytes:&c length:1]; 32 | switch (c) { 33 | case 0xFF: 34 | return SDImageFormatJPEG; 35 | case 0x89: 36 | return SDImageFormatPNG; 37 | case 0x47: 38 | return SDImageFormatGIF; 39 | case 0x49: 40 | case 0x4D: 41 | return SDImageFormatTIFF; 42 | case 0x52: { 43 | if (data.length >= 12) { 44 | //RIFF....WEBP 45 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; 46 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { 47 | return SDImageFormatWebP; 48 | } 49 | } 50 | break; 51 | } 52 | case 0x00: { 53 | if (data.length >= 12) { 54 | //....ftypheic ....ftypheix ....ftyphevc ....ftyphevx 55 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(4, 8)] encoding:NSASCIIStringEncoding]; 56 | if ([testString isEqualToString:@"ftypheic"] 57 | || [testString isEqualToString:@"ftypheix"] 58 | || [testString isEqualToString:@"ftyphevc"] 59 | || [testString isEqualToString:@"ftyphevx"]) { 60 | return SDImageFormatHEIC; 61 | } 62 | } 63 | break; 64 | } 65 | } 66 | return SDImageFormatUndefined; 67 | } 68 | 69 | + (nonnull CFStringRef)sd_UTTypeFromSDImageFormat:(SDImageFormat)format { 70 | CFStringRef UTType; 71 | switch (format) { 72 | case SDImageFormatJPEG: 73 | UTType = kUTTypeJPEG; 74 | break; 75 | case SDImageFormatPNG: 76 | UTType = kUTTypePNG; 77 | break; 78 | case SDImageFormatGIF: 79 | UTType = kUTTypeGIF; 80 | break; 81 | case SDImageFormatTIFF: 82 | UTType = kUTTypeTIFF; 83 | break; 84 | case SDImageFormatWebP: 85 | UTType = kSDUTTypeWebP; 86 | break; 87 | case SDImageFormatHEIC: 88 | UTType = kSDUTTypeHEIC; 89 | break; 90 | default: 91 | // default is kUTTypePNG 92 | UTType = kUTTypePNG; 93 | break; 94 | } 95 | return UTType; 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/NSImage+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 | 11 | #if SD_MAC 12 | 13 | #import 14 | 15 | @interface NSImage (WebCache) 16 | 17 | - (CGImageRef)CGImage; 18 | - (NSArray *)images; 19 | - (BOOL)isGIF; 20 | 21 | @end 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/NSImage+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 "NSImage+WebCache.h" 10 | 11 | #if SD_MAC 12 | 13 | @implementation NSImage (WebCache) 14 | 15 | - (CGImageRef)CGImage { 16 | NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height); 17 | CGImageRef cgImage = [self CGImageForProposedRect:&imageRect context:NULL hints:nil]; 18 | return cgImage; 19 | } 20 | 21 | - (NSArray *)images { 22 | return nil; 23 | } 24 | 25 | - (BOOL)isGIF { 26 | BOOL isGIF = NO; 27 | for (NSImageRep *rep in self.representations) { 28 | if ([rep isKindOfClass:[NSBitmapImageRep class]]) { 29 | NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep; 30 | NSUInteger frameCount = [[bitmapRep valueForProperty:NSImageFrameCount] unsignedIntegerValue]; 31 | isGIF = frameCount > 1 ? YES : NO; 32 | break; 33 | } 34 | } 35 | return isGIF; 36 | } 37 | 38 | @end 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDAnimatedImageRep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if SD_MAC 12 | 13 | // A subclass of `NSBitmapImageRep` to fix that GIF loop count issue because `NSBitmapImageRep` will reset `NSImageCurrentFrameDuration` by using `kCGImagePropertyGIFDelayTime` but not `kCGImagePropertyGIFUnclampedDelayTime`. 14 | // Built in GIF coder use this instead of `NSBitmapImageRep` for better GIF rendering. If you do not want this, only enable `SDWebImageImageIOCoder`, which just call `NSImage` API and actually use `NSBitmapImageRep` for GIF image. 15 | 16 | @interface SDAnimatedImageRep : NSBitmapImageRep 17 | 18 | @end 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDAnimatedImageRep.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 "SDAnimatedImageRep.h" 10 | 11 | #if SD_MAC 12 | 13 | #import "SDWebImageGIFCoder.h" 14 | 15 | @interface SDWebImageGIFCoder () 16 | 17 | - (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source; 18 | 19 | @end 20 | 21 | @interface SDAnimatedImageRep () 22 | 23 | @property (nonatomic, assign, readonly, nullable) CGImageSourceRef imageSource; 24 | 25 | @end 26 | 27 | @implementation SDAnimatedImageRep 28 | 29 | // `NSBitmapImageRep` will use `kCGImagePropertyGIFDelayTime` whenever you call `setProperty:withValue:` with `NSImageCurrentFrame` to change the current frame. We override it and use the actual `kCGImagePropertyGIFUnclampedDelayTime` if need. 30 | - (void)setProperty:(NSBitmapImageRepPropertyKey)property withValue:(id)value { 31 | [super setProperty:property withValue:value]; 32 | if ([property isEqualToString:NSImageCurrentFrame]) { 33 | // Access the image source 34 | CGImageSourceRef imageSource = self.imageSource; 35 | if (!imageSource) { 36 | return; 37 | } 38 | // Check format type 39 | CFStringRef type = CGImageSourceGetType(imageSource); 40 | if (!type) { 41 | return; 42 | } 43 | NSUInteger index = [value unsignedIntegerValue]; 44 | float frameDuration = 0; 45 | // Through we currently process GIF only, in the 5.x we support APNG so we keep the extensibility 46 | if (CFStringCompare(type, kUTTypeGIF, 0) == kCFCompareEqualTo) { 47 | frameDuration = [[SDWebImageGIFCoder sharedCoder] sd_frameDurationAtIndex:index source:imageSource]; 48 | } 49 | if (!frameDuration) { 50 | return; 51 | } 52 | // Reset super frame duration with the actual frame duration 53 | [super setProperty:NSImageCurrentFrameDuration withValue:@(frameDuration)]; 54 | } 55 | } 56 | 57 | - (CGImageSourceRef)imageSource { 58 | if (_tiffData) { 59 | return (__bridge CGImageSourceRef)(_tiffData); 60 | } 61 | return NULL; 62 | } 63 | 64 | @end 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | @interface SDImageCacheConfig : NSObject 13 | 14 | /** 15 | * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. 16 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. 17 | */ 18 | @property (assign, nonatomic) BOOL shouldDecompressImages; 19 | 20 | /** 21 | * disable iCloud backup [defaults to YES] 22 | */ 23 | @property (assign, nonatomic) BOOL shouldDisableiCloud; 24 | 25 | /** 26 | * use memory cache [defaults to YES] 27 | */ 28 | @property (assign, nonatomic) BOOL shouldCacheImagesInMemory; 29 | 30 | /** 31 | * The reading options while reading cache from disk. 32 | * Defaults to 0. You can set this to `NSDataReadingMappedIfSafe` to improve performance. 33 | */ 34 | @property (assign, nonatomic) NSDataReadingOptions diskCacheReadingOptions; 35 | 36 | /** 37 | * The writing options while writing cache to disk. 38 | * Defaults to `NSDataWritingAtomic`. You can set this to `NSDataWritingWithoutOverwriting` to prevent overwriting an existing file. 39 | */ 40 | @property (assign, nonatomic) NSDataWritingOptions diskCacheWritingOptions; 41 | 42 | /** 43 | * The maximum length of time to keep an image in the cache, in seconds. 44 | */ 45 | @property (assign, nonatomic) NSInteger maxCacheAge; 46 | 47 | /** 48 | * The maximum size of the cache, in bytes. 49 | */ 50 | @property (assign, nonatomic) NSUInteger maxCacheSize; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDImageCacheConfig.h" 10 | 11 | static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week 12 | 13 | @implementation SDImageCacheConfig 14 | 15 | - (instancetype)init { 16 | if (self = [super init]) { 17 | _shouldDecompressImages = YES; 18 | _shouldDisableiCloud = YES; 19 | _shouldCacheImagesInMemory = YES; 20 | _diskCacheReadingOptions = 0; 21 | _diskCacheWritingOptions = NSDataWritingAtomic; 22 | _maxCacheAge = kDefaultCacheMaxCacheAge; 23 | _maxCacheSize = 0; 24 | } 25 | return self; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageCoder.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 "NSData+ImageContentType.h" 12 | 13 | /** 14 | A Boolean value indicating whether to scale down large images during decompressing. (NSNumber) 15 | */ 16 | FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageCoderScaleDownLargeImagesKey; 17 | 18 | /** 19 | Return the shared device-dependent RGB color space created with CGColorSpaceCreateDeviceRGB. 20 | 21 | @return The device-dependent RGB color space 22 | */ 23 | CG_EXTERN CGColorSpaceRef _Nonnull SDCGColorSpaceGetDeviceRGB(void); 24 | 25 | /** 26 | Check whether CGImageRef contains alpha channel. 27 | 28 | @param imageRef The CGImageRef 29 | @return Return YES if CGImageRef contains alpha channel, otherwise return NO 30 | */ 31 | CG_EXTERN BOOL SDCGImageRefContainsAlpha(_Nullable CGImageRef imageRef); 32 | 33 | 34 | /** 35 | This is the image coder protocol to provide custom image decoding/encoding. 36 | These methods are all required to implement. 37 | @note Pay attention that these methods are not called from main queue. 38 | */ 39 | @protocol SDWebImageCoder 40 | 41 | @required 42 | #pragma mark - Decoding 43 | /** 44 | Returns YES if this coder can decode some data. Otherwise, the data should be passed to another coder. 45 | 46 | @param data The image data so we can look at it 47 | @return YES if this coder can decode the data, NO otherwise 48 | */ 49 | - (BOOL)canDecodeFromData:(nullable NSData *)data; 50 | 51 | /** 52 | Decode the image data to image. 53 | 54 | @param data The image data to be decoded 55 | @return The decoded image from data 56 | */ 57 | - (nullable UIImage *)decodedImageWithData:(nullable NSData *)data; 58 | 59 | /** 60 | Decompress the image with original image and image data. 61 | 62 | @param image The original image to be decompressed 63 | @param data The pointer to original image data. The pointer itself is nonnull but image data can be null. This data will set to cache if needed. If you do not need to modify data at the sametime, ignore this param. 64 | @param optionsDict A dictionary containing any decompressing options. Pass {SDWebImageCoderScaleDownLargeImagesKey: @(YES)} to scale down large images 65 | @return The decompressed image 66 | */ 67 | - (nullable UIImage *)decompressedImageWithImage:(nullable UIImage *)image 68 | data:(NSData * _Nullable * _Nonnull)data 69 | options:(nullable NSDictionary*)optionsDict; 70 | 71 | #pragma mark - Encoding 72 | 73 | /** 74 | Returns YES if this coder can encode some image. Otherwise, it should be passed to another coder. 75 | 76 | @param format The image format 77 | @return YES if this coder can encode the image, NO otherwise 78 | */ 79 | - (BOOL)canEncodeToFormat:(SDImageFormat)format; 80 | 81 | /** 82 | Encode the image to image data. 83 | 84 | @param image The image to be encoded 85 | @param format The image format to encode, you should note `SDImageFormatUndefined` format is also possible 86 | @return The encoded image data 87 | */ 88 | - (nullable NSData *)encodedDataWithImage:(nullable UIImage *)image format:(SDImageFormat)format; 89 | 90 | @end 91 | 92 | 93 | /** 94 | This is the image coder protocol to provide custom progressive image decoding. 95 | These methods are all required to implement. 96 | @note Pay attention that these methods are not called from main queue. 97 | */ 98 | @protocol SDWebImageProgressiveCoder 99 | 100 | @required 101 | /** 102 | Returns YES if this coder can incremental decode some data. Otherwise, it should be passed to another coder. 103 | 104 | @param data The image data so we can look at it 105 | @return YES if this coder can decode the data, NO otherwise 106 | */ 107 | - (BOOL)canIncrementallyDecodeFromData:(nullable NSData *)data; 108 | 109 | /** 110 | Incremental decode the image data to image. 111 | 112 | @param data The image data has been downloaded so far 113 | @param finished Whether the download has finished 114 | @warning because incremental decoding need to keep the decoded context, we will alloc a new instance with the same class for each download operation to avoid conflicts 115 | @return The decoded image from data 116 | */ 117 | - (nullable UIImage *)incrementallyDecodedImageWithData:(nullable NSData *)data finished:(BOOL)finished; 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageCoder.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 "SDWebImageCoder.h" 10 | 11 | NSString * const SDWebImageCoderScaleDownLargeImagesKey = @"scaleDownLargeImages"; 12 | 13 | CGColorSpaceRef SDCGColorSpaceGetDeviceRGB(void) { 14 | static CGColorSpaceRef colorSpace; 15 | static dispatch_once_t onceToken; 16 | dispatch_once(&onceToken, ^{ 17 | colorSpace = CGColorSpaceCreateDeviceRGB(); 18 | }); 19 | return colorSpace; 20 | } 21 | 22 | BOOL SDCGImageRefContainsAlpha(CGImageRef imageRef) { 23 | if (!imageRef) { 24 | return NO; 25 | } 26 | CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef); 27 | BOOL hasAlpha = !(alphaInfo == kCGImageAlphaNone || 28 | alphaInfo == kCGImageAlphaNoneSkipFirst || 29 | alphaInfo == kCGImageAlphaNoneSkipLast); 30 | return hasAlpha; 31 | } 32 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageCoderHelper.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 "SDWebImageFrame.h" 12 | 13 | @interface SDWebImageCoderHelper : NSObject 14 | 15 | /** 16 | Return an animated image with frames array. 17 | For UIKit, this will apply the patch and then create animated UIImage. The patch is because that `+[UIImage animatedImageWithImages:duration:]` just use the average of duration for each image. So it will not work if different frame has different duration. Therefore we repeat the specify frame for specify times to let it work. 18 | For AppKit, NSImage does not support animates other than GIF. This will try to encode the frames to GIF format and then create an animated NSImage for rendering. Attention the animated image may loss some detail if the input frames contain full alpha channel because GIF only supports 1 bit alpha channel. (For 1 pixel, either transparent or not) 19 | 20 | @param frames The frames array. If no frames or frames is empty, return nil 21 | @return A animated image for rendering on UIImageView(UIKit) or NSImageView(AppKit) 22 | */ 23 | + (UIImage * _Nullable)animatedImageWithFrames:(NSArray * _Nullable)frames; 24 | 25 | /** 26 | Return frames array from an animated image. 27 | For UIKit, this will unapply the patch for the description above and then create frames array. This will also work for normal animated UIImage. 28 | For AppKit, NSImage does not support animates other than GIF. This will try to decode the GIF imageRep and then create frames array. 29 | 30 | @param animatedImage A animated image. If it's not animated, return nil 31 | @return The frames array 32 | */ 33 | + (NSArray * _Nullable)framesFromAnimatedImage:(UIImage * _Nullable)animatedImage; 34 | 35 | #if SD_UIKIT || SD_WATCH 36 | /** 37 | Convert an EXIF image orientation to an iOS one. 38 | 39 | @param exifOrientation EXIF orientation 40 | @return iOS orientation 41 | */ 42 | + (UIImageOrientation)imageOrientationFromEXIFOrientation:(NSInteger)exifOrientation; 43 | /** 44 | Convert an iOS orientation to an EXIF image orientation. 45 | 46 | @param imageOrientation iOS orientation 47 | @return EXIF orientation 48 | */ 49 | + (NSInteger)exifOrientationFromImageOrientation:(UIImageOrientation)imageOrientation; 50 | #endif 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageCodersManager.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 "SDWebImageCoder.h" 11 | 12 | /** 13 | Global object holding the array of coders, so that we avoid passing them from object to object. 14 | Uses a priority queue behind scenes, which means the latest added coders have the highest priority. 15 | This is done so when encoding/decoding something, we go through the list and ask each coder if they can handle the current data. 16 | That way, users can add their custom coders while preserving our existing prebuilt ones 17 | 18 | Note: the `coders` getter will return the coders in their reversed order 19 | Example: 20 | - by default we internally set coders = `IOCoder`, `WebPCoder`. (`GIFCoder` is not recommended to add only if you want to get GIF support without `FLAnimatedImage`) 21 | - calling `coders` will return `@[WebPCoder, IOCoder]` 22 | - call `[addCoder:[MyCrazyCoder new]]` 23 | - calling `coders` now returns `@[MyCrazyCoder, WebPCoder, IOCoder]` 24 | 25 | Coders 26 | ------ 27 | A coder must conform to the `SDWebImageCoder` protocol or even to `SDWebImageProgressiveCoder` if it supports progressive decoding 28 | Conformance is important because that way, they will implement `canDecodeFromData` or `canEncodeToFormat` 29 | Those methods are called on each coder in the array (using the priority order) until one of them returns YES. 30 | That means that coder can decode that data / encode to that format 31 | */ 32 | @interface SDWebImageCodersManager : NSObject 33 | 34 | /** 35 | Shared reusable instance 36 | */ 37 | + (nonnull instancetype)sharedInstance; 38 | 39 | /** 40 | All coders in coders manager. The coders array is a priority queue, which means the later added coder will have the highest priority 41 | */ 42 | @property (nonatomic, strong, readwrite, nullable) NSArray* coders; 43 | 44 | /** 45 | Add a new coder to the end of coders array. Which has the highest priority. 46 | 47 | @param coder coder 48 | */ 49 | - (void)addCoder:(nonnull id)coder; 50 | 51 | /** 52 | Remove a coder in the coders array. 53 | 54 | @param coder coder 55 | */ 56 | - (void)removeCoder:(nonnull id)coder; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageCodersManager.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 "SDWebImageCodersManager.h" 10 | #import "SDWebImageImageIOCoder.h" 11 | #import "SDWebImageGIFCoder.h" 12 | #ifdef SD_WEBP 13 | #import "SDWebImageWebPCoder.h" 14 | #endif 15 | 16 | @interface SDWebImageCodersManager () 17 | 18 | @property (strong, nonatomic, nonnull) NSMutableArray* mutableCoders; 19 | @property (strong, nonatomic, nullable) dispatch_queue_t mutableCodersAccessQueue; 20 | 21 | @end 22 | 23 | @implementation SDWebImageCodersManager 24 | 25 | + (nonnull instancetype)sharedInstance { 26 | static dispatch_once_t once; 27 | static id instance; 28 | dispatch_once(&once, ^{ 29 | instance = [self new]; 30 | }); 31 | return instance; 32 | } 33 | 34 | - (instancetype)init { 35 | if (self = [super init]) { 36 | // initialize with default coders 37 | _mutableCoders = [@[[SDWebImageImageIOCoder sharedCoder]] mutableCopy]; 38 | #ifdef SD_WEBP 39 | [_mutableCoders addObject:[SDWebImageWebPCoder sharedCoder]]; 40 | #endif 41 | _mutableCodersAccessQueue = dispatch_queue_create("com.hackemist.SDWebImageCodersManager", DISPATCH_QUEUE_CONCURRENT); 42 | } 43 | return self; 44 | } 45 | 46 | #pragma mark - Coder IO operations 47 | 48 | - (void)addCoder:(nonnull id)coder { 49 | if ([coder conformsToProtocol:@protocol(SDWebImageCoder)]) { 50 | dispatch_barrier_sync(self.mutableCodersAccessQueue, ^{ 51 | [self.mutableCoders addObject:coder]; 52 | }); 53 | } 54 | } 55 | 56 | - (void)removeCoder:(nonnull id)coder { 57 | dispatch_barrier_sync(self.mutableCodersAccessQueue, ^{ 58 | [self.mutableCoders removeObject:coder]; 59 | }); 60 | } 61 | 62 | - (NSArray *)coders { 63 | __block NSArray *sortedCoders = nil; 64 | dispatch_sync(self.mutableCodersAccessQueue, ^{ 65 | sortedCoders = (NSArray *)[[[self.mutableCoders copy] reverseObjectEnumerator] allObjects]; 66 | }); 67 | return sortedCoders; 68 | } 69 | 70 | - (void)setCoders:(NSArray *)coders { 71 | dispatch_barrier_sync(self.mutableCodersAccessQueue, ^{ 72 | self.mutableCoders = [coders mutableCopy]; 73 | }); 74 | } 75 | 76 | #pragma mark - SDWebImageCoder 77 | - (BOOL)canDecodeFromData:(NSData *)data { 78 | for (id coder in self.coders) { 79 | if ([coder canDecodeFromData:data]) { 80 | return YES; 81 | } 82 | } 83 | return NO; 84 | } 85 | 86 | - (BOOL)canEncodeToFormat:(SDImageFormat)format { 87 | for (id coder in self.coders) { 88 | if ([coder canEncodeToFormat:format]) { 89 | return YES; 90 | } 91 | } 92 | return NO; 93 | } 94 | 95 | - (UIImage *)decodedImageWithData:(NSData *)data { 96 | if (!data) { 97 | return nil; 98 | } 99 | for (id coder in self.coders) { 100 | if ([coder canDecodeFromData:data]) { 101 | return [coder decodedImageWithData:data]; 102 | } 103 | } 104 | return nil; 105 | } 106 | 107 | - (UIImage *)decompressedImageWithImage:(UIImage *)image 108 | data:(NSData *__autoreleasing _Nullable *)data 109 | options:(nullable NSDictionary*)optionsDict { 110 | if (!image) { 111 | return nil; 112 | } 113 | for (id coder in self.coders) { 114 | if ([coder canDecodeFromData:*data]) { 115 | return [coder decompressedImageWithImage:image data:data options:optionsDict]; 116 | } 117 | } 118 | return nil; 119 | } 120 | 121 | - (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format { 122 | if (!image) { 123 | return nil; 124 | } 125 | for (id coder in self.coders) { 126 | if ([coder canEncodeToFormat:format]) { 127 | return [coder encodedDataWithImage:image format:format]; 128 | } 129 | } 130 | return nil; 131 | } 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /Tool/demo/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 | // Apple's defines from TargetConditionals.h are a bit weird. 17 | // Seems like TARGET_OS_MAC is always defined (on all platforms). 18 | // To determine if we are running on OSX, we can only rely on TARGET_OS_IPHONE=0 and all the other platforms 19 | #if !TARGET_OS_IPHONE && !TARGET_OS_IOS && !TARGET_OS_TV && !TARGET_OS_WATCH 20 | #define SD_MAC 1 21 | #else 22 | #define SD_MAC 0 23 | #endif 24 | 25 | // iOS and tvOS are very similar, UIKit exists on both platforms 26 | // Note: watchOS also has UIKit, but it's very limited 27 | #if TARGET_OS_IOS || TARGET_OS_TV 28 | #define SD_UIKIT 1 29 | #else 30 | #define SD_UIKIT 0 31 | #endif 32 | 33 | #if TARGET_OS_IOS 34 | #define SD_IOS 1 35 | #else 36 | #define SD_IOS 0 37 | #endif 38 | 39 | #if TARGET_OS_TV 40 | #define SD_TV 1 41 | #else 42 | #define SD_TV 0 43 | #endif 44 | 45 | #if TARGET_OS_WATCH 46 | #define SD_WATCH 1 47 | #else 48 | #define SD_WATCH 0 49 | #endif 50 | 51 | 52 | #if SD_MAC 53 | #import 54 | #ifndef UIImage 55 | #define UIImage NSImage 56 | #endif 57 | #ifndef UIImageView 58 | #define UIImageView NSImageView 59 | #endif 60 | #ifndef UIView 61 | #define UIView NSView 62 | #endif 63 | #else 64 | #if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 65 | #error SDWebImage doesn't support Deployment Target version < 5.0 66 | #endif 67 | 68 | #if SD_UIKIT 69 | #import 70 | #endif 71 | #if SD_WATCH 72 | #import 73 | #endif 74 | #endif 75 | 76 | #ifndef NS_ENUM 77 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 78 | #endif 79 | 80 | #ifndef NS_OPTIONS 81 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 82 | #endif 83 | 84 | FOUNDATION_EXPORT UIImage *SDScaledImageForKey(NSString *key, UIImage *image); 85 | 86 | typedef void(^SDWebImageNoParamsBlock)(void); 87 | 88 | FOUNDATION_EXPORT NSString *const SDWebImageErrorDomain; 89 | 90 | #ifndef dispatch_queue_async_safe 91 | #define dispatch_queue_async_safe(queue, block)\ 92 | if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) {\ 93 | block();\ 94 | } else {\ 95 | dispatch_async(queue, block);\ 96 | } 97 | #endif 98 | 99 | #ifndef dispatch_main_async_safe 100 | #define dispatch_main_async_safe(block) dispatch_queue_async_safe(dispatch_get_main_queue(), block) 101 | #endif 102 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "UIImage+MultiFormat.h" 11 | 12 | #if !__has_feature(objc_arc) 13 | #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag 14 | #endif 15 | 16 | #if !OS_OBJECT_USE_OBJC 17 | #error SDWebImage need ARC for dispatch object 18 | #endif 19 | 20 | inline UIImage *SDScaledImageForKey(NSString * _Nullable key, UIImage * _Nullable image) { 21 | if (!image) { 22 | return nil; 23 | } 24 | 25 | #if SD_MAC 26 | return image; 27 | #elif SD_UIKIT || SD_WATCH 28 | if ((image.images).count > 0) { 29 | NSMutableArray *scaledImages = [NSMutableArray array]; 30 | 31 | for (UIImage *tempImage in image.images) { 32 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; 33 | } 34 | 35 | UIImage *animatedImage = [UIImage animatedImageWithImages:scaledImages duration:image.duration]; 36 | if (animatedImage) { 37 | animatedImage.sd_imageLoopCount = image.sd_imageLoopCount; 38 | } 39 | return animatedImage; 40 | } else { 41 | #if SD_WATCH 42 | if ([[WKInterfaceDevice currentDevice] respondsToSelector:@selector(screenScale)]) { 43 | #elif SD_UIKIT 44 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 45 | #endif 46 | CGFloat scale = 1; 47 | if (key.length >= 8) { 48 | NSRange range = [key rangeOfString:@"@2x."]; 49 | if (range.location != NSNotFound) { 50 | scale = 2.0; 51 | } 52 | 53 | range = [key rangeOfString:@"@3x."]; 54 | if (range.location != NSNotFound) { 55 | scale = 3.0; 56 | } 57 | } 58 | 59 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; 60 | image = scaledImage; 61 | } 62 | return image; 63 | } 64 | #endif 65 | } 66 | 67 | NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; 68 | -------------------------------------------------------------------------------- /Tool/demo/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 | FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageDownloadStartNotification; 14 | FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageDownloadReceiveResponseNotification; 15 | FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageDownloadStopNotification; 16 | FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageDownloadFinishNotification; 17 | 18 | 19 | 20 | /** 21 | Describes a downloader operation. If one wants to use a custom downloader op, it needs to inherit from `NSOperation` and conform to this protocol 22 | For the description about these methods, see `SDWebImageDownloaderOperation` 23 | */ 24 | @protocol SDWebImageDownloaderOperationInterface 25 | 26 | - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request 27 | inSession:(nullable NSURLSession *)session 28 | options:(SDWebImageDownloaderOptions)options; 29 | 30 | - (nullable id)addHandlersForProgress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 31 | completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; 32 | 33 | - (BOOL)shouldDecompressImages; 34 | - (void)setShouldDecompressImages:(BOOL)value; 35 | 36 | - (nullable NSURLCredential *)credential; 37 | - (void)setCredential:(nullable NSURLCredential *)value; 38 | 39 | - (BOOL)cancel:(nullable id)token; 40 | 41 | @end 42 | 43 | 44 | @interface SDWebImageDownloaderOperation : NSOperation 45 | 46 | /** 47 | * The request used by the operation's task. 48 | */ 49 | @property (strong, nonatomic, readonly, nullable) NSURLRequest *request; 50 | 51 | /** 52 | * The operation's task 53 | */ 54 | @property (strong, nonatomic, readonly, nullable) NSURLSessionTask *dataTask; 55 | 56 | 57 | @property (assign, nonatomic) BOOL shouldDecompressImages; 58 | 59 | /** 60 | * Was used to determine whether the URL connection should consult the credential storage for authenticating the connection. 61 | * @deprecated Not used for a couple of versions 62 | */ 63 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage __deprecated_msg("Property deprecated. Does nothing. Kept only for backwards compatibility"); 64 | 65 | /** 66 | * The credential used for authentication challenges in `-URLSession:task:didReceiveChallenge:completionHandler:`. 67 | * 68 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. 69 | */ 70 | @property (nonatomic, strong, nullable) NSURLCredential *credential; 71 | 72 | /** 73 | * The SDWebImageDownloaderOptions for the receiver. 74 | */ 75 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; 76 | 77 | /** 78 | * The expected size of data. 79 | */ 80 | @property (assign, nonatomic) NSInteger expectedSize; 81 | 82 | /** 83 | * The response returned by the operation's task. 84 | */ 85 | @property (strong, nonatomic, nullable) NSURLResponse *response; 86 | 87 | /** 88 | * Initializes a `SDWebImageDownloaderOperation` object 89 | * 90 | * @see SDWebImageDownloaderOperation 91 | * 92 | * @param request the URL request 93 | * @param session the URL session in which this operation will run 94 | * @param options downloader options 95 | * 96 | * @return the initialized instance 97 | */ 98 | - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request 99 | inSession:(nullable NSURLSession *)session 100 | options:(SDWebImageDownloaderOptions)options NS_DESIGNATED_INITIALIZER; 101 | 102 | /** 103 | * Adds handlers for progress and completion. Returns a tokent that can be passed to -cancel: to cancel this set of 104 | * callbacks. 105 | * 106 | * @param progressBlock the block executed when a new chunk of data arrives. 107 | * @note the progress block is executed on a background queue 108 | * @param completedBlock the block executed when the download is done. 109 | * @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 110 | * 111 | * @return the token to use to cancel this set of handlers 112 | */ 113 | - (nullable id)addHandlersForProgress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 114 | completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; 115 | 116 | /** 117 | * Cancels a set of callbacks. Once all callbacks are canceled, the operation is cancelled. 118 | * 119 | * @param token the token representing a set of callbacks to cancel 120 | * 121 | * @return YES if the operation was stopped because this was the last token to be canceled. NO otherwise. 122 | */ 123 | - (BOOL)cancel:(nullable id)token; 124 | 125 | @end 126 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageFrame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | @interface SDWebImageFrame : NSObject 13 | 14 | // This class is used for creating animated images via `animatedImageWithFrames` in `SDWebImageCoderHelper`. Attention if you need to specify animated images loop count, use `sd_imageLoopCount` property in `UIImage+MultiFormat`. 15 | 16 | /** 17 | The image of current frame. You should not set an animated image. 18 | */ 19 | @property (nonatomic, strong, readonly, nonnull) UIImage *image; 20 | /** 21 | The duration of current frame to be displayed. The number is seconds but not milliseconds. You should not set this to zero. 22 | */ 23 | @property (nonatomic, readonly, assign) NSTimeInterval duration; 24 | 25 | /** 26 | Create a frame instance with specify image and duration 27 | 28 | @param image current frame's image 29 | @param duration current frame's duration 30 | @return frame instance 31 | */ 32 | + (instancetype _Nonnull)frameWithImage:(UIImage * _Nonnull)image duration:(NSTimeInterval)duration; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageFrame.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 "SDWebImageFrame.h" 10 | 11 | @interface SDWebImageFrame () 12 | 13 | @property (nonatomic, strong, readwrite, nonnull) UIImage *image; 14 | @property (nonatomic, readwrite, assign) NSTimeInterval duration; 15 | 16 | @end 17 | 18 | @implementation SDWebImageFrame 19 | 20 | + (instancetype)frameWithImage:(UIImage *)image duration:(NSTimeInterval)duration { 21 | SDWebImageFrame *frame = [[SDWebImageFrame alloc] init]; 22 | frame.image = image; 23 | frame.duration = duration; 24 | 25 | return frame; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageGIFCoder.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 "SDWebImageCoder.h" 11 | 12 | /** 13 | Built in coder using ImageIO that supports GIF encoding/decoding 14 | @note `SDWebImageIOCoder` supports GIF but only as static (will use the 1st frame). 15 | @note Use `SDWebImageGIFCoder` for fully animated GIFs - less performant than `FLAnimatedImage` 16 | @note If you decide to make all `UIImageView`(including `FLAnimatedImageView`) instance support GIF. You should add this coder to `SDWebImageCodersManager` and make sure that it has a higher priority than `SDWebImageIOCoder` 17 | @note The recommended approach for animated GIFs is using `FLAnimatedImage`. It's more performant than `UIImageView` for GIF displaying 18 | */ 19 | @interface SDWebImageGIFCoder : NSObject 20 | 21 | + (nonnull instancetype)sharedCoder; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageImageIOCoder.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 "SDWebImageCoder.h" 11 | 12 | /** 13 | Built in coder that supports PNG, JPEG, TIFF, includes support for progressive decoding. 14 | 15 | GIF 16 | Also supports static GIF (meaning will only handle the 1st frame). 17 | For a full GIF support, we recommend `FLAnimatedImage` or our less performant `SDWebImageGIFCoder` 18 | 19 | HEIC 20 | This coder also supports HEIC format because ImageIO supports it natively. But it depends on the system capabilities, so it won't work on all devices, see: https://devstreaming-cdn.apple.com/videos/wwdc/2017/511tj33587vdhds/511/511_working_with_heif_and_hevc.pdf 21 | Decode(Software): !Simulator && (iOS 11 || tvOS 11 || macOS 10.13) 22 | Decode(Hardware): !Simulator && ((iOS 11 && A9Chip) || (macOS 10.13 && 6thGenerationIntelCPU)) 23 | Encode(Software): macOS 10.13 24 | Encode(Hardware): !Simulator && ((iOS 11 && A10FusionChip) || (macOS 10.13 && 6thGenerationIntelCPU)) 25 | */ 26 | @interface SDWebImageImageIOCoder : NSObject 27 | 28 | + (nonnull instancetype)sharedCoder; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Tool/demo/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 | -------------------------------------------------------------------------------- /Tool/demo/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:(nonnull SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(nullable 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:(nonnull 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, nonnull) 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 | /** 62 | * Queue options for Prefetcher. Defaults to Main Queue. 63 | */ 64 | @property (strong, nonatomic, nonnull) dispatch_queue_t prefetcherQueue; 65 | 66 | @property (weak, nonatomic, nullable) id delegate; 67 | 68 | /** 69 | * Return the global image prefetcher instance. 70 | */ 71 | + (nonnull instancetype)sharedImagePrefetcher; 72 | 73 | /** 74 | * Allows you to instantiate a prefetcher with any arbitrary image manager. 75 | */ 76 | - (nonnull instancetype)initWithImageManager:(nonnull SDWebImageManager *)manager NS_DESIGNATED_INITIALIZER; 77 | 78 | /** 79 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 80 | * currently one image is downloaded at a time, 81 | * and skips images for failed downloads and proceed to the next image in the list. 82 | * Any previously-running prefetch operations are canceled. 83 | * 84 | * @param urls list of URLs to prefetch 85 | */ 86 | - (void)prefetchURLs:(nullable NSArray *)urls; 87 | 88 | /** 89 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 90 | * currently one image is downloaded at a time, 91 | * and skips images for failed downloads and proceed to the next image in the list. 92 | * Any previously-running prefetch operations are canceled. 93 | * 94 | * @param urls list of URLs to prefetch 95 | * @param progressBlock block to be called when progress updates; 96 | * first parameter is the number of completed (successful or not) requests, 97 | * second parameter is the total number of images originally requested to be prefetched 98 | * @param completionBlock block to be called when prefetching is completed 99 | * first param is the number of completed (successful or not) requests, 100 | * second parameter is the number of skipped requests 101 | */ 102 | - (void)prefetchURLs:(nullable NSArray *)urls 103 | progress:(nullable SDWebImagePrefetcherProgressBlock)progressBlock 104 | completed:(nullable SDWebImagePrefetcherCompletionBlock)completionBlock; 105 | 106 | /** 107 | * Remove and cancel queued list 108 | */ 109 | - (void)cancelPrefetching; 110 | 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /Tool/demo/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 | @interface SDWebImagePrefetcher () 12 | 13 | @property (strong, nonatomic, nonnull) SDWebImageManager *manager; 14 | @property (strong, atomic, nullable) NSArray *prefetchURLs; // may be accessed from different queue 15 | @property (assign, nonatomic) NSUInteger requestedCount; 16 | @property (assign, nonatomic) NSUInteger skippedCount; 17 | @property (assign, nonatomic) NSUInteger finishedCount; 18 | @property (assign, nonatomic) NSTimeInterval startedTime; 19 | @property (copy, nonatomic, nullable) SDWebImagePrefetcherCompletionBlock completionBlock; 20 | @property (copy, nonatomic, nullable) SDWebImagePrefetcherProgressBlock progressBlock; 21 | 22 | @end 23 | 24 | @implementation SDWebImagePrefetcher 25 | 26 | + (nonnull instancetype)sharedImagePrefetcher { 27 | static dispatch_once_t once; 28 | static id instance; 29 | dispatch_once(&once, ^{ 30 | instance = [self new]; 31 | }); 32 | return instance; 33 | } 34 | 35 | - (nonnull instancetype)init { 36 | return [self initWithImageManager:[SDWebImageManager new]]; 37 | } 38 | 39 | - (nonnull instancetype)initWithImageManager:(SDWebImageManager *)manager { 40 | if ((self = [super init])) { 41 | _manager = manager; 42 | _options = SDWebImageLowPriority; 43 | _prefetcherQueue = dispatch_get_main_queue(); 44 | self.maxConcurrentDownloads = 3; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { 50 | self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; 51 | } 52 | 53 | - (NSUInteger)maxConcurrentDownloads { 54 | return self.manager.imageDownloader.maxConcurrentDownloads; 55 | } 56 | 57 | - (void)startPrefetchingAtIndex:(NSUInteger)index { 58 | NSURL *currentURL; 59 | @synchronized(self) { 60 | if (index >= self.prefetchURLs.count) return; 61 | currentURL = self.prefetchURLs[index]; 62 | self.requestedCount++; 63 | } 64 | [self.manager loadImageWithURL:currentURL options:self.options progress:nil completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 65 | if (!finished) return; 66 | self.finishedCount++; 67 | 68 | if (self.progressBlock) { 69 | self.progressBlock(self.finishedCount,(self.prefetchURLs).count); 70 | } 71 | if (!image) { 72 | // Add last failed 73 | self.skippedCount++; 74 | } 75 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { 76 | [self.delegate imagePrefetcher:self 77 | didPrefetchURL:currentURL 78 | finishedCount:self.finishedCount 79 | totalCount:self.prefetchURLs.count 80 | ]; 81 | } 82 | if (self.prefetchURLs.count > self.requestedCount) { 83 | dispatch_async(self.prefetcherQueue, ^{ 84 | // we need dispatch to avoid function recursion call. This can prevent stack overflow even for huge urls list 85 | [self startPrefetchingAtIndex:self.requestedCount]; 86 | }); 87 | } else if (self.finishedCount == self.requestedCount) { 88 | [self reportStatus]; 89 | if (self.completionBlock) { 90 | self.completionBlock(self.finishedCount, self.skippedCount); 91 | self.completionBlock = nil; 92 | } 93 | self.progressBlock = nil; 94 | } 95 | }]; 96 | } 97 | 98 | - (void)reportStatus { 99 | NSUInteger total = (self.prefetchURLs).count; 100 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { 101 | [self.delegate imagePrefetcher:self 102 | didFinishWithTotalCount:(total - self.skippedCount) 103 | skippedCount:self.skippedCount 104 | ]; 105 | } 106 | } 107 | 108 | - (void)prefetchURLs:(nullable NSArray *)urls { 109 | [self prefetchURLs:urls progress:nil completed:nil]; 110 | } 111 | 112 | - (void)prefetchURLs:(nullable NSArray *)urls 113 | progress:(nullable SDWebImagePrefetcherProgressBlock)progressBlock 114 | completed:(nullable SDWebImagePrefetcherCompletionBlock)completionBlock { 115 | [self cancelPrefetching]; // Prevent duplicate prefetch request 116 | self.startedTime = CFAbsoluteTimeGetCurrent(); 117 | self.prefetchURLs = urls; 118 | self.completionBlock = completionBlock; 119 | self.progressBlock = progressBlock; 120 | 121 | if (urls.count == 0) { 122 | if (completionBlock) { 123 | completionBlock(0,0); 124 | } 125 | } else { 126 | // Starts prefetching from the very first image on the list with the max allowed concurrency 127 | NSUInteger listCount = self.prefetchURLs.count; 128 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { 129 | [self startPrefetchingAtIndex:i]; 130 | } 131 | } 132 | } 133 | 134 | - (void)cancelPrefetching { 135 | @synchronized(self) { 136 | self.prefetchURLs = nil; 137 | self.skippedCount = 0; 138 | self.requestedCount = 0; 139 | self.finishedCount = 0; 140 | } 141 | [self.manager cancelAll]; 142 | } 143 | 144 | @end 145 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageTransition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if SD_UIKIT || SD_MAC 12 | #import "SDImageCache.h" 13 | 14 | // This class is used to provide a transition animation after the view category load image finished. Use this on `sd_imageTransition` in UIView+WebCache.h 15 | // for UIKit(iOS & tvOS), we use `+[UIView transitionWithView:duration:options:animations:completion]` for transition animation. 16 | // for AppKit(macOS), we use `+[NSAnimationContext runAnimationGroup:completionHandler:]` for transition animation. You can call `+[NSAnimationContext currentContext]` to grab the context during animations block. 17 | // These transition are provided for basic usage. If you need complicated animation, consider to directly use Core Animation or use `SDWebImageAvoidAutoSetImage` and implement your own after image load finished. 18 | 19 | #if SD_UIKIT 20 | typedef UIViewAnimationOptions SDWebImageAnimationOptions; 21 | #else 22 | typedef NS_OPTIONS(NSUInteger, SDWebImageAnimationOptions) { 23 | SDWebImageAnimationOptionAllowsImplicitAnimation = 1 << 0, // specify `allowsImplicitAnimation` for the `NSAnimationContext` 24 | }; 25 | #endif 26 | 27 | typedef void (^SDWebImageTransitionPreparesBlock)(__kindof UIView * _Nonnull view, UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL); 28 | typedef void (^SDWebImageTransitionAnimationsBlock)(__kindof UIView * _Nonnull view, UIImage * _Nullable image); 29 | typedef void (^SDWebImageTransitionCompletionBlock)(BOOL finished); 30 | 31 | @interface SDWebImageTransition : NSObject 32 | 33 | /** 34 | By default, we set the image to the view at the beginning of the animtions. You can disable this and provide custom set image process 35 | */ 36 | @property (nonatomic, assign) BOOL avoidAutoSetImage; 37 | /** 38 | The duration of the transition animation, measured in seconds. Defaults to 0.5. 39 | */ 40 | @property (nonatomic, assign) NSTimeInterval duration; 41 | /** 42 | The timing function used for all animations within this transition animation (macOS). 43 | */ 44 | @property (nonatomic, strong, nullable) CAMediaTimingFunction *timingFunction NS_AVAILABLE_MAC(10_7); 45 | /** 46 | A mask of options indicating how you want to perform the animations. 47 | */ 48 | @property (nonatomic, assign) SDWebImageAnimationOptions animationOptions; 49 | /** 50 | A block object to be executed before the animation sequence starts. 51 | */ 52 | @property (nonatomic, copy, nullable) SDWebImageTransitionPreparesBlock prepares; 53 | /** 54 | A block object that contains the changes you want to make to the specified view. 55 | */ 56 | @property (nonatomic, copy, nullable) SDWebImageTransitionAnimationsBlock animations; 57 | /** 58 | A block object to be executed when the animation sequence ends. 59 | */ 60 | @property (nonatomic, copy, nullable) SDWebImageTransitionCompletionBlock completion; 61 | 62 | @end 63 | 64 | // Convenience way to create transition. Remember to specify the duration if needed. 65 | // for UIKit, these transition just use the correspond `animationOptions` 66 | // for AppKit, these transition use Core Animation in `animations`. So your view must be layer-backed. Set `wantsLayer = YES` before you apply it. 67 | 68 | @interface SDWebImageTransition (Conveniences) 69 | 70 | // class property is available in Xcode 8. We will drop the Xcode 7.3 support in 5.x 71 | #if __has_feature(objc_class_property) 72 | /// Fade transition. 73 | @property (nonatomic, class, nonnull, readonly) SDWebImageTransition *fadeTransition; 74 | /// Flip from left transition. 75 | @property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromLeftTransition; 76 | /// Flip from right transition. 77 | @property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromRightTransition; 78 | /// Flip from top transition. 79 | @property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromTopTransition; 80 | /// Flip from bottom transition. 81 | @property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromBottomTransition; 82 | /// Curl up transition. 83 | @property (nonatomic, class, nonnull, readonly) SDWebImageTransition *curlUpTransition; 84 | /// Curl down transition. 85 | @property (nonatomic, class, nonnull, readonly) SDWebImageTransition *curlDownTransition; 86 | #else 87 | + (nonnull instancetype)fadeTransition; 88 | + (nonnull instancetype)flipFromLeftTransition; 89 | + (nonnull instancetype)flipFromRightTransition; 90 | + (nonnull instancetype)flipFromTopTransition; 91 | + (nonnull instancetype)flipFromBottomTransition; 92 | + (nonnull instancetype)curlUpTransition; 93 | + (nonnull instancetype)curlDownTransition; 94 | #endif 95 | 96 | @end 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/SDWebImageTransition.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 "SDWebImageTransition.h" 10 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #if SD_MAC 14 | #import 15 | #endif 16 | 17 | @implementation SDWebImageTransition 18 | 19 | - (instancetype)init { 20 | self = [super init]; 21 | if (self) { 22 | self.duration = 0.5; 23 | } 24 | return self; 25 | } 26 | 27 | @end 28 | 29 | @implementation SDWebImageTransition (Conveniences) 30 | 31 | + (SDWebImageTransition *)fadeTransition { 32 | SDWebImageTransition *transition = [SDWebImageTransition new]; 33 | #if SD_UIKIT 34 | transition.animationOptions = UIViewAnimationOptionTransitionCrossDissolve; 35 | #else 36 | transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { 37 | CATransition *trans = [CATransition animation]; 38 | trans.type = kCATransitionFade; 39 | [view.layer addAnimation:trans forKey:kCATransition]; 40 | }; 41 | #endif 42 | return transition; 43 | } 44 | 45 | + (SDWebImageTransition *)flipFromLeftTransition { 46 | SDWebImageTransition *transition = [SDWebImageTransition new]; 47 | #if SD_UIKIT 48 | transition.animationOptions = UIViewAnimationOptionTransitionFlipFromLeft; 49 | #else 50 | transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { 51 | CATransition *trans = [CATransition animation]; 52 | trans.type = kCATransitionPush; 53 | trans.subtype = kCATransitionFromLeft; 54 | [view.layer addAnimation:trans forKey:kCATransition]; 55 | }; 56 | #endif 57 | return transition; 58 | } 59 | 60 | + (SDWebImageTransition *)flipFromRightTransition { 61 | SDWebImageTransition *transition = [SDWebImageTransition new]; 62 | #if SD_UIKIT 63 | transition.animationOptions = UIViewAnimationOptionTransitionFlipFromRight; 64 | #else 65 | transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { 66 | CATransition *trans = [CATransition animation]; 67 | trans.type = kCATransitionPush; 68 | trans.subtype = kCATransitionFromRight; 69 | [view.layer addAnimation:trans forKey:kCATransition]; 70 | }; 71 | #endif 72 | return transition; 73 | } 74 | 75 | + (SDWebImageTransition *)flipFromTopTransition { 76 | SDWebImageTransition *transition = [SDWebImageTransition new]; 77 | #if SD_UIKIT 78 | transition.animationOptions = UIViewAnimationOptionTransitionFlipFromTop; 79 | #else 80 | transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { 81 | CATransition *trans = [CATransition animation]; 82 | trans.type = kCATransitionPush; 83 | trans.subtype = kCATransitionFromTop; 84 | [view.layer addAnimation:trans forKey:kCATransition]; 85 | }; 86 | #endif 87 | return transition; 88 | } 89 | 90 | + (SDWebImageTransition *)flipFromBottomTransition { 91 | SDWebImageTransition *transition = [SDWebImageTransition new]; 92 | #if SD_UIKIT 93 | transition.animationOptions = UIViewAnimationOptionTransitionFlipFromBottom; 94 | #else 95 | transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { 96 | CATransition *trans = [CATransition animation]; 97 | trans.type = kCATransitionPush; 98 | trans.subtype = kCATransitionFromBottom; 99 | [view.layer addAnimation:trans forKey:kCATransition]; 100 | }; 101 | #endif 102 | return transition; 103 | } 104 | 105 | + (SDWebImageTransition *)curlUpTransition { 106 | SDWebImageTransition *transition = [SDWebImageTransition new]; 107 | #if SD_UIKIT 108 | transition.animationOptions = UIViewAnimationOptionTransitionCurlUp; 109 | #else 110 | transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { 111 | CATransition *trans = [CATransition animation]; 112 | trans.type = kCATransitionReveal; 113 | trans.subtype = kCATransitionFromTop; 114 | [view.layer addAnimation:trans forKey:kCATransition]; 115 | }; 116 | #endif 117 | return transition; 118 | } 119 | 120 | + (SDWebImageTransition *)curlDownTransition { 121 | SDWebImageTransition *transition = [SDWebImageTransition new]; 122 | #if SD_UIKIT 123 | transition.animationOptions = UIViewAnimationOptionTransitionCurlDown; 124 | #else 125 | transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { 126 | CATransition *trans = [CATransition animation]; 127 | trans.type = kCATransitionReveal; 128 | trans.subtype = kCATransitionFromBottom; 129 | [view.layer addAnimation:trans forKey:kCATransition]; 130 | }; 131 | #endif 132 | return transition; 133 | } 134 | 135 | @end 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/UIImage+ForceDecode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | @interface UIImage (ForceDecode) 12 | 13 | + (nullable UIImage *)decodedImageWithImage:(nullable UIImage *)image; 14 | 15 | + (nullable UIImage *)decodedAndScaledDownImageWithImage:(nullable UIImage *)image; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/UIImage+ForceDecode.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImage+ForceDecode.h" 10 | #import "SDWebImageCodersManager.h" 11 | 12 | @implementation UIImage (ForceDecode) 13 | 14 | + (UIImage *)decodedImageWithImage:(UIImage *)image { 15 | if (!image) { 16 | return nil; 17 | } 18 | NSData *tempData; 19 | return [[SDWebImageCodersManager sharedInstance] decompressedImageWithImage:image data:&tempData options:@{SDWebImageCoderScaleDownLargeImagesKey: @(NO)}]; 20 | } 21 | 22 | + (UIImage *)decodedAndScaledDownImageWithImage:(UIImage *)image { 23 | if (!image) { 24 | return nil; 25 | } 26 | NSData *tempData; 27 | return [[SDWebImageCodersManager sharedInstance] decompressedImageWithImage:image data:&tempData options:@{SDWebImageCoderScaleDownLargeImagesKey: @(YES)}]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Laurin Brandner 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import "SDWebImageCompat.h" 11 | 12 | @interface UIImage (GIF) 13 | 14 | /** 15 | * Creates an animated UIImage from an NSData. 16 | * For static GIF, will create an UIImage with `images` array set to nil. For animated GIF, will create an UIImage with valid `images` array. 17 | */ 18 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data; 19 | 20 | /** 21 | * Checks if an UIImage instance is a GIF. Will use the `images` array. 22 | */ 23 | - (BOOL)isGIF; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/UIImage+GIF.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Laurin Brandner 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import "UIImage+GIF.h" 11 | #import "SDWebImageGIFCoder.h" 12 | #import "NSImage+WebCache.h" 13 | 14 | @implementation UIImage (GIF) 15 | 16 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data { 17 | if (!data) { 18 | return nil; 19 | } 20 | return [[SDWebImageGIFCoder sharedCoder] decodedImageWithData:data]; 21 | } 22 | 23 | - (BOOL)isGIF { 24 | return (self.images != nil); 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "NSData+ImageContentType.h" 11 | 12 | @interface UIImage (MultiFormat) 13 | 14 | /** 15 | * UIKit: 16 | * For static image format, this value is always 0. 17 | * For animated image format, 0 means infinite looping. 18 | * Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods. 19 | * AppKit: 20 | * NSImage currently only support animated via GIF imageRep unlike UIImage. 21 | * The getter of this property will get the loop count from GIF imageRep 22 | * The setter of this property will set the loop count from GIF imageRep 23 | */ 24 | @property (nonatomic, assign) NSUInteger sd_imageLoopCount; 25 | 26 | + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data; 27 | - (nullable NSData *)sd_imageData; 28 | - (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Tool/demo/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImage+MultiFormat.h" 10 | 11 | #import "objc/runtime.h" 12 | #import "SDWebImageCodersManager.h" 13 | 14 | @implementation UIImage (MultiFormat) 15 | 16 | #if SD_MAC 17 | - (NSUInteger)sd_imageLoopCount { 18 | NSUInteger imageLoopCount = 0; 19 | for (NSImageRep *rep in self.representations) { 20 | if ([rep isKindOfClass:[NSBitmapImageRep class]]) { 21 | NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep; 22 | imageLoopCount = [[bitmapRep valueForProperty:NSImageLoopCount] unsignedIntegerValue]; 23 | break; 24 | } 25 | } 26 | return imageLoopCount; 27 | } 28 | 29 | - (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount { 30 | for (NSImageRep *rep in self.representations) { 31 | if ([rep isKindOfClass:[NSBitmapImageRep class]]) { 32 | NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep; 33 | [bitmapRep setProperty:NSImageLoopCount withValue:@(sd_imageLoopCount)]; 34 | break; 35 | } 36 | } 37 | } 38 | 39 | #else 40 | 41 | - (NSUInteger)sd_imageLoopCount { 42 | NSUInteger imageLoopCount = 0; 43 | NSNumber *value = objc_getAssociatedObject(self, @selector(sd_imageLoopCount)); 44 | if ([value isKindOfClass:[NSNumber class]]) { 45 | imageLoopCount = value.unsignedIntegerValue; 46 | } 47 | return imageLoopCount; 48 | } 49 | 50 | - (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount { 51 | NSNumber *value = @(sd_imageLoopCount); 52 | objc_setAssociatedObject(self, @selector(sd_imageLoopCount), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 53 | } 54 | #endif 55 | 56 | + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data { 57 | return [[SDWebImageCodersManager sharedInstance] decodedImageWithData:data]; 58 | } 59 | 60 | - (nullable NSData *)sd_imageData { 61 | return [self sd_imageDataAsFormat:SDImageFormatUndefined]; 62 | } 63 | 64 | - (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat { 65 | NSData *imageData = nil; 66 | if (self) { 67 | imageData = [[SDWebImageCodersManager sharedInstance] encodedDataWithImage:self format:imageFormat]; 68 | } 69 | return imageData; 70 | } 71 | 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Tool/demo/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 "SDWebImageCompat.h" 10 | 11 | #if SD_UIKIT 12 | 13 | #import "SDWebImageManager.h" 14 | 15 | /** 16 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. 17 | */ 18 | @interface UIImageView (HighlightedWebCache) 19 | 20 | /** 21 | * Set the imageView `highlightedImage` with an `url`. 22 | * 23 | * The download is asynchronous and cached. 24 | * 25 | * @param url The url for the image. 26 | */ 27 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; 28 | 29 | /** 30 | * Set the imageView `highlightedImage` with an `url` and custom options. 31 | * 32 | * The download is asynchronous and cached. 33 | * 34 | * @param url The url for the image. 35 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 36 | */ 37 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 38 | options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; 39 | 40 | /** 41 | * Set the imageView `highlightedImage` with an `url`. 42 | * 43 | * The download is asynchronous and cached. 44 | * 45 | * @param url The url for the image. 46 | * @param completedBlock A block called when operation has been completed. This block has no return value 47 | * and takes the requested UIImage as first parameter. In case of error the image parameter 48 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 49 | * indicating if the image was retrieved from the local cache or from the network. 50 | * The fourth parameter is the original image url. 51 | */ 52 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 53 | completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; 54 | 55 | /** 56 | * Set the imageView `highlightedImage` with an `url` and custom options. 57 | * 58 | * The download is asynchronous and cached. 59 | * 60 | * @param url The url for the image. 61 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 62 | * @param completedBlock A block called when operation has been completed. This block has no return value 63 | * and takes the requested UIImage as first parameter. In case of error the image parameter 64 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 65 | * indicating if the image was retrieved from the local cache or from the network. 66 | * The fourth parameter is the original image url. 67 | */ 68 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 69 | options:(SDWebImageOptions)options 70 | completed:(nullable SDExternalCompletionBlock)completedBlock; 71 | 72 | /** 73 | * Set the imageView `highlightedImage` with an `url` and custom options. 74 | * 75 | * The download is asynchronous and cached. 76 | * 77 | * @param url The url for the image. 78 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 79 | * @param progressBlock A block called while image is downloading 80 | * @note the progress block is executed on a background queue 81 | * @param completedBlock A block called when operation has been completed. This block has no return value 82 | * and takes the requested UIImage as first parameter. In case of error the image parameter 83 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 84 | * indicating if the image was retrieved from the local cache or from the network. 85 | * The fourth parameter is the original image url. 86 | */ 87 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 88 | options:(SDWebImageOptions)options 89 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 90 | completed:(nullable SDExternalCompletionBlock)completedBlock; 91 | 92 | @end 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Tool/demo/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 | 11 | #if SD_UIKIT 12 | 13 | #import "UIView+WebCacheOperation.h" 14 | #import "UIView+WebCache.h" 15 | 16 | @implementation UIImageView (HighlightedWebCache) 17 | 18 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url { 19 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 20 | } 21 | 22 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options { 23 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 24 | } 25 | 26 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { 27 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; 28 | } 29 | 30 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { 31 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; 32 | } 33 | 34 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 35 | options:(SDWebImageOptions)options 36 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 37 | completed:(nullable SDExternalCompletionBlock)completedBlock { 38 | __weak typeof(self)weakSelf = self; 39 | [self sd_internalSetImageWithURL:url 40 | placeholderImage:nil 41 | options:options 42 | operationKey:@"UIImageViewImageOperationHighlighted" 43 | setImageBlock:^(UIImage *image, NSData *imageData) { 44 | weakSelf.highlightedImage = image; 45 | } 46 | progress:progressBlock 47 | completed:completedBlock]; 48 | } 49 | 50 | @end 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Tool/demo/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 "SDWebImageCompat.h" 10 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #import "SDWebImageManager.h" 14 | 15 | // These methods are used to support canceling for UIView image loading, it's designed to be used internal but not external. 16 | // All the stored operations are weak, so it will be dalloced after image loading finished. If you need to store operations, use your own class to keep a strong reference for them. 17 | @interface UIView (WebCacheOperation) 18 | 19 | /** 20 | * Set the image load operation (storage in a UIView based weak map table) 21 | * 22 | * @param operation the operation 23 | * @param key key for storing the operation 24 | */ 25 | - (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key; 26 | 27 | /** 28 | * Cancel all operations for the current UIView and key 29 | * 30 | * @param key key for identifying the operations 31 | */ 32 | - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key; 33 | 34 | /** 35 | * Just remove the operations corresponding to the current UIView and key without cancelling them 36 | * 37 | * @param key key for identifying the operations 38 | */ 39 | - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key; 40 | 41 | @end 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Tool/demo/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 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #import "objc/runtime.h" 14 | 15 | static char loadOperationKey; 16 | 17 | // key is copy, value is weak because operation instance is retained by SDWebImageManager's runningOperations property 18 | // we should use lock to keep thread-safe because these method may not be acessed from main queue 19 | typedef NSMapTable> SDOperationsDictionary; 20 | 21 | @implementation UIView (WebCacheOperation) 22 | 23 | - (SDOperationsDictionary *)sd_operationDictionary { 24 | @synchronized(self) { 25 | SDOperationsDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); 26 | if (operations) { 27 | return operations; 28 | } 29 | operations = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsWeakMemory capacity:0]; 30 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 31 | return operations; 32 | } 33 | } 34 | 35 | - (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key { 36 | if (key) { 37 | [self sd_cancelImageLoadOperationWithKey:key]; 38 | if (operation) { 39 | SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; 40 | @synchronized (self) { 41 | [operationDictionary setObject:operation forKey:key]; 42 | } 43 | } 44 | } 45 | } 46 | 47 | - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key { 48 | // Cancel in progress downloader from queue 49 | SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; 50 | id operation; 51 | @synchronized (self) { 52 | operation = [operationDictionary objectForKey:key]; 53 | } 54 | if (operation) { 55 | if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]){ 56 | [operation cancel]; 57 | } 58 | @synchronized (self) { 59 | [operationDictionary removeObjectForKey:key]; 60 | } 61 | } 62 | } 63 | 64 | - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key { 65 | if (key) { 66 | SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; 67 | @synchronized (self) { 68 | [operationDictionary removeObjectForKey:key]; 69 | } 70 | } 71 | } 72 | 73 | @end 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Masonry/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Masonry/Masonry-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Masonry : NSObject 3 | @end 4 | @implementation PodsDummy_Masonry 5 | @end 6 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Masonry/Masonry-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Masonry/Masonry-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "MASCompositeConstraint.h" 14 | #import "MASConstraint+Private.h" 15 | #import "MASConstraint.h" 16 | #import "MASConstraintMaker.h" 17 | #import "MASLayoutConstraint.h" 18 | #import "Masonry.h" 19 | #import "MASUtilities.h" 20 | #import "MASViewAttribute.h" 21 | #import "MASViewConstraint.h" 22 | #import "NSArray+MASAdditions.h" 23 | #import "NSArray+MASShorthandAdditions.h" 24 | #import "NSLayoutConstraint+MASDebugAdditions.h" 25 | #import "View+MASAdditions.h" 26 | #import "View+MASShorthandAdditions.h" 27 | #import "ViewController+MASAdditions.h" 28 | 29 | FOUNDATION_EXPORT double MasonryVersionNumber; 30 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 31 | 32 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Masonry/Masonry.modulemap: -------------------------------------------------------------------------------- 1 | framework module Masonry { 2 | umbrella header "Masonry-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Masonry/Masonry.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Masonry 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Masonry 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Pods-Tool/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Pods-Tool/Pods-Tool-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Masonry 5 | 6 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 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 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all 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 | ## SDWebImage 27 | 28 | Copyright (c) 2009-2017 Olivier Poitrey rs@dailymotion.com 29 | 30 | Permission is hereby granted, free of charge, to any person obtaining a copy 31 | of this software and associated documentation files (the "Software"), to deal 32 | in the Software without restriction, including without limitation the rights 33 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 34 | copies of the Software, and to permit persons to whom the Software is furnished 35 | to do so, subject to the following conditions: 36 | 37 | The above copyright notice and this permission notice shall be included in all 38 | copies or substantial portions of the Software. 39 | 40 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 41 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 42 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 43 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 44 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 45 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 46 | THE SOFTWARE. 47 | 48 | 49 | Generated by CocoaPods - https://cocoapods.org 50 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Pods-Tool/Pods-Tool-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) 2011-2012 Masonry Team - https://github.com/Masonry 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 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all 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 | License 37 | MIT 38 | Title 39 | Masonry 40 | Type 41 | PSGroupSpecifier 42 | 43 | 44 | FooterText 45 | Copyright (c) 2009-2017 Olivier Poitrey rs@dailymotion.com 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy 48 | of this software and associated documentation files (the "Software"), to deal 49 | in the Software without restriction, including without limitation the rights 50 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 51 | copies of the Software, and to permit persons to whom the Software is furnished 52 | to do so, subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included in all 55 | copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 60 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 62 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 63 | THE SOFTWARE. 64 | 65 | 66 | License 67 | MIT 68 | Title 69 | SDWebImage 70 | Type 71 | PSGroupSpecifier 72 | 73 | 74 | FooterText 75 | Generated by CocoaPods - https://cocoapods.org 76 | Title 77 | 78 | Type 79 | PSGroupSpecifier 80 | 81 | 82 | StringsTable 83 | Acknowledgements 84 | Title 85 | Acknowledgements 86 | 87 | 88 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Pods-Tool/Pods-Tool-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Tool : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Tool 5 | @end 6 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Pods-Tool/Pods-Tool-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_ToolVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_ToolVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Pods-Tool/Pods-Tool.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "Masonry" -framework "SDWebImage" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Pods-Tool/Pods-Tool.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_Tool { 2 | umbrella header "Pods-Tool-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/Pods-Tool/Pods-Tool.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "Masonry" -framework "SDWebImage" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/SDWebImage/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 4.3.3 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SDWebImage : NSObject 3 | @end 4 | @implementation PodsDummy_SDWebImage 5 | @end 6 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "NSButton+WebCache.h" 14 | #import "NSData+ImageContentType.h" 15 | #import "NSImage+WebCache.h" 16 | #import "SDAnimatedImageRep.h" 17 | #import "SDImageCache.h" 18 | #import "SDImageCacheConfig.h" 19 | #import "SDWebImageCoder.h" 20 | #import "SDWebImageCoderHelper.h" 21 | #import "SDWebImageCodersManager.h" 22 | #import "SDWebImageCompat.h" 23 | #import "SDWebImageDownloader.h" 24 | #import "SDWebImageDownloaderOperation.h" 25 | #import "SDWebImageFrame.h" 26 | #import "SDWebImageGIFCoder.h" 27 | #import "SDWebImageImageIOCoder.h" 28 | #import "SDWebImageManager.h" 29 | #import "SDWebImageOperation.h" 30 | #import "SDWebImagePrefetcher.h" 31 | #import "SDWebImageTransition.h" 32 | #import "UIButton+WebCache.h" 33 | #import "UIImage+ForceDecode.h" 34 | #import "UIImage+GIF.h" 35 | #import "UIImage+MultiFormat.h" 36 | #import "UIImageView+HighlightedWebCache.h" 37 | #import "UIImageView+WebCache.h" 38 | #import "UIView+WebCache.h" 39 | #import "UIView+WebCacheOperation.h" 40 | 41 | FOUNDATION_EXPORT double SDWebImageVersionNumber; 42 | FOUNDATION_EXPORT const unsigned char SDWebImageVersionString[]; 43 | 44 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/SDWebImage/SDWebImage.modulemap: -------------------------------------------------------------------------------- 1 | framework module SDWebImage { 2 | umbrella header "SDWebImage-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Tool/demo/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_LDFLAGS = -framework "ImageIO" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SDWebImage 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Tool/demo/Tool.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tool/demo/Tool.xcodeproj/project.xcworkspace/xcuserdata/jackson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwantFB/iOS_Tool/65e192877d7993ee0f47961a6de129473fc14c59/Tool/demo/Tool.xcodeproj/project.xcworkspace/xcuserdata/jackson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Tool/demo/Tool.xcodeproj/xcuserdata/jackson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Tool.xcscheme 8 | 9 | orderHint 10 | 3 11 | 12 | Tool.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 3 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tool/demo/Tool.xcodeproj/xcuserdata/yezhan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Tool.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Tool/demo/Tool.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Tool/demo/Tool.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Tool/demo/Tool.xcworkspace/xcuserdata/jackson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwantFB/iOS_Tool/65e192877d7993ee0f47961a6de129473fc14c59/Tool/demo/Tool.xcworkspace/xcuserdata/jackson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Tool/demo/Tool.xcworkspace/xcuserdata/yezhan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwantFB/iOS_Tool/65e192877d7993ee0f47961a6de129473fc14c59/Tool/demo/Tool.xcworkspace/xcuserdata/yezhan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Tool/demo/Tool.xcworkspace/xcuserdata/yezhan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Tool/demo/Tool/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Tool 4 | // 5 | // Created by 胡斐 on 2018/5/19. 6 | // Copyright © 2018年 jackson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Tool/demo/Tool/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Tool 4 | // 5 | // Created by 胡斐 on 2018/5/19. 6 | // Copyright © 2018年 jackson. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | return YES; 22 | } 23 | 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application { 26 | // 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. 27 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 28 | } 29 | 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application { 32 | // 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. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application { 38 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application { 43 | // 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. 44 | } 45 | 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application { 48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 49 | } 50 | 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Tool/demo/Tool/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Tool/demo/Tool/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tool/demo/Tool/Assets.xcassets/lady.imageset/140-1F123155215.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwantFB/iOS_Tool/65e192877d7993ee0f47961a6de129473fc14c59/Tool/demo/Tool/Assets.xcassets/lady.imageset/140-1F123155215.jpg -------------------------------------------------------------------------------- /Tool/demo/Tool/Assets.xcassets/lady.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "140-1F123155215.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Tool/demo/Tool/Assets.xcassets/timg.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "timg.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Tool/demo/Tool/Assets.xcassets/timg.imageset/timg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwantFB/iOS_Tool/65e192877d7993ee0f47961a6de129473fc14c59/Tool/demo/Tool/Assets.xcassets/timg.imageset/timg.jpg -------------------------------------------------------------------------------- /Tool/demo/Tool/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Tool/demo/Tool/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Tool/demo/Tool/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Demo 4 | // 5 | // Created by 胡斐 on 2018/4/26. 6 | // Copyright © 2018年 jackson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UITableViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Tool/demo/Tool/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Demo 4 | // 5 | // Created by 胡斐 on 2018/4/26. 6 | // Copyright © 2018年 jackson. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "HFCircleImageView.h" 11 | #import "YZVerifyButton.h" 12 | #import "FHClipImageViewController.h" 13 | #import "AvatarListView.h" 14 | 15 | #import "FHAlertSheetView.h" 16 | 17 | #import "HFGradientButton.h" 18 | 19 | 20 | @interface ViewController () 21 | @property (weak, nonatomic) IBOutlet UIImageView *resultImageView; 22 | @property (weak, nonatomic) IBOutlet HFCircleImageView *imageView; 23 | @property (weak, nonatomic) IBOutlet AvatarListView *avatarListView; 24 | @property (weak, nonatomic) IBOutlet HFGradientButton *footerButton; 25 | 26 | @end 27 | 28 | @implementation ViewController 29 | 30 | - (void)viewDidLoad { 31 | [super viewDidLoad]; 32 | // Do any additional setup after loading the view, typically from a nib. 33 | 34 | _imageView.cornerSize = CGSizeMake(5, 5); 35 | 36 | //个人觉得设置图片的z-position不是一种特别好的办法,还是要重写flowlayout试试 37 | _avatarListView.avatarArr = @[@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3912945903,2440251137&fm=27&gp=0.jpg",]; 38 | _avatarListView.configration = [AvatarListConfigration defaultConfigration]; 39 | _avatarListView.selectedBlock = ^(NSInteger item) { 40 | NSLog(@"点击的是%ld",(long)item); 41 | }; 42 | 43 | [_footerButton buildHorizBtnColorWithColors:@[(id)[UIColor redColor].CGColor,(id)[UIColor orangeColor].CGColor]]; 44 | } 45 | 46 | - (IBAction)startCount:(YZVerifyButton *)sender { 47 | //验证码都是网络请求成功之后开始计时,故提供开启计时的方法 48 | [sender openCountdown]; 49 | } 50 | - (IBAction)clipImageGestureAction:(id)sender { 51 | 52 | //图片固定裁剪,希望有好的思路可以提给我,谢谢,主要是固定比例暂时没有好的思路 53 | FHClipImageViewController *vc = [[FHClipImageViewController alloc] initWithTargetImage:[UIImage imageNamed:@"lady"] maskFrame:CGRectMake(40, 40, 300, 500) clipBlock:^(UIImage *result) { 54 | _resultImageView.image = result; 55 | }]; 56 | [self.navigationController pushViewController:vc animated:YES]; 57 | } 58 | - (IBAction)checkSheetView:(id)sender { 59 | //cancel 会自动分到下一组去,分组有且只有2组,可以设置间隔 60 | FHAlertSheetView *alert = [FHAlertSheetView alertControllerWithTitle:@"头" message:@"message" preferredStyle:FHAlertControllerStyleActionSheet]; 61 | FHAlertAction *action1 = [FHAlertAction actionWithTitle:@"one" style:FHAlertActionStyleDefault handler:^(FHAlertAction *action) { 62 | NSLog(@"one"); 63 | }]; 64 | FHAlertAction *action2 = [FHAlertAction actionWithTitle:@"two" fontSize:30 textColor:[UIColor yellowColor] style:FHAlertActionStyleDefault handler:^(FHAlertAction *action) { 65 | NSLog(@"two"); 66 | }]; 67 | FHAlertAction *action3 = [FHAlertAction actionWithTitle:@"three" style:FHAlertActionStyleCancel handler:^(FHAlertAction *action) { 68 | NSLog(@"three"); 69 | }]; 70 | [alert addAction:action1]; 71 | [alert addAction:action2]; 72 | [alert addAction:action3]; 73 | [alert show]; 74 | 75 | } 76 | 77 | - (void)didReceiveMemoryWarning { 78 | [super didReceiveMemoryWarning]; 79 | // Dispose of any resources that can be recreated. 80 | } 81 | 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/AvatarListView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AvatarListView.h 3 | // DEMO 4 | // 5 | // Created by 夜站 on 2018/3/16. 6 | // Copyright © 2018年 夜站. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, AvatarViewCoverType){ 12 | ///右边压住左边 13 | AvatarViewCoverTypeRight, 14 | AvatarViewCoverTypeLeft, 15 | AvatarViewCoverTypeNone 16 | }; 17 | 18 | @interface AvatarListConfigration : NSObject 19 | 20 | @property (nonatomic) CGFloat itemHeight; 21 | @property (nonatomic) CGFloat itemWidth; 22 | @property (nonatomic, strong) UIColor *borderColor; 23 | @property (nonatomic) CGFloat borderWidth; 24 | @property (nonatomic) CGFloat cornerRadius; 25 | @property (nonatomic,) AvatarViewCoverType coverType; 26 | @property (nonatomic,) CGFloat coverSpace; 27 | //图片之间的间距设置这个值之后会默认覆盖掉coverType, coverSpace 28 | @property (nonatomic,) CGFloat avatarMargin; 29 | //距离上左下右的距离 30 | @property (nonatomic,) UIEdgeInsets edges; 31 | //图片占位图 32 | @property (nonatomic, copy)NSString *placeHolderImageStr; 33 | 34 | + (instancetype)defaultConfigration; 35 | 36 | @end 37 | 38 | @interface AvatarListView : UIView 39 | 40 | @property (nonatomic, strong)AvatarListConfigration *configration; 41 | 42 | @property (nonatomic, copy)NSArray *avatarArr; 43 | 44 | @property (nonatomic, copy) void(^selectedBlock)(NSInteger item); 45 | 46 | - (instancetype)initWithFrame:(CGRect)frame 47 | configration:(AvatarListConfigration *)configration 48 | avatarArr:(NSArray *)avatarArr selectedBlock:(void(^)(NSInteger item)) selectedBlock; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/FHSegmentView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FHSegmentView.h 3 | // DEMO 4 | // 5 | // Created by 夜站 on 2018/3/19. 6 | // Copyright © 2018年 夜站. All rights reserved. 7 | // 8 | 9 | #import 10 | @class FHSegmentView; 11 | 12 | @protocol FHSegmentViewDelegate 13 | 14 | - (void)segmentView:(FHSegmentView *)segmentView 15 | didSelectedTab:(NSInteger)selectedTab; 16 | 17 | @end 18 | 19 | @interface FHSegmentConfiguration : NSObject 20 | 21 | @property (nonatomic, strong) UIFont *fontForSelect; 22 | @property (nonatomic, strong) UIFont *fontForNormal; 23 | 24 | @property (nonatomic, strong) UIColor *textColorForNormal; 25 | @property (nonatomic, strong) UIColor *textColorForSelected; 26 | @property (nonatomic, strong) UIColor *bgColorForNormal; 27 | @property (nonatomic, strong) UIColor *bgColorForSelected; 28 | 29 | @property (nonatomic, assign) CGFloat cornerRadius; 30 | @property (nonatomic, assign) CGFloat itemWidth; 31 | @property (nonatomic, assign) CGFloat itemHeight; 32 | @property (nonatomic, assign) CGFloat itemSpace; 33 | /** 34 | 是否自动将按钮居中,若为YES,只要设置itemWidth和itemHeight和itemSpace 35 | 若为NO,则需要设置insets和itemSpace 36 | */ 37 | @property (nonatomic, assign) BOOL adjustCenter; 38 | @property (nonatomic, assign) UIEdgeInsets insets; 39 | 40 | ///顶部的数据的高度 41 | @property (nonatomic, assign) CGFloat segmentHeight; 42 | 43 | /**顶部按钮的背景视图的颜色*/ 44 | @property (nonatomic, strong) UIColor *segmentColor; 45 | ///默认为NO,不显示分割线 46 | @property (nonatomic, assign) BOOL needSeparator; 47 | @property (nonatomic, strong) UIColor *separatorColor; 48 | @property (nonatomic, assign) UIEdgeInsets separatorInset; 49 | @property (nonatomic, assign) CGFloat indexViewWidth; 50 | @property (nonatomic, assign) CGFloat indexViewHeight; 51 | @property (nonatomic, assign) CGFloat indexViewBottomMargin; 52 | @property (nonatomic, strong) UIColor *indexViewColor; 53 | 54 | @property (nonatomic) BOOL scrollEnable; 55 | @property (nonatomic) BOOL scrollAnimation; 56 | 57 | + (instancetype)defaluConfiguration; 58 | 59 | @end 60 | 61 | @interface FHSegmentView : UIView 62 | 63 | ///若要改变,调用selectIndex: animation: 64 | @property (nonatomic, assign, readonly) NSInteger currentIndex; 65 | 66 | 67 | /**设置某个控制器会将superViewController设置为childVCArr中的vc的父控制器,用来做控制器管理*/ 68 | @property (nonatomic, strong)UIViewController *superViewController; 69 | 70 | @property (nonatomic, strong)FHSegmentConfiguration *configration; 71 | 72 | @property (nonatomic, weak) iddelegate; 73 | 74 | ///在buildUI之前设置 75 | @property (nonatomic, copy) NSArray *childVCArr; 76 | 77 | - (instancetype)initWithFrame:(CGRect)frame 78 | childVCArr:(nonnull NSArray *)childVCArr 79 | configration:(nullable FHSegmentConfiguration *)configration; 80 | 81 | /// 配置好了数据之后开始配置视图,这应该是放在最后的 82 | - (void)buildUI; 83 | 84 | /**选择哪一个tab*/ 85 | - (void)selectIndex:(NSInteger )index animation:(BOOL)animation; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HFCircleImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFCircleImageView.h 3 | // DEMO 4 | // 5 | // Created by 胡斐 on 2018/1/19. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | #import 9 | 10 | @interface HFCircleImageView : UIImageView 11 | 12 | /*圆角Size**/ 13 | @property (nonatomic, assign)CGSize cornerSize; 14 | 15 | @property (nonatomic, assign) CGFloat boarderWidth; 16 | @property (nonatomic, strong) UIColor *boarderColor; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HFCircleImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // HFCircleImageView.m 3 | // DEMO 4 | // 5 | // Created by 胡斐 on 2018/1/19. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import "HFCircleImageView.h" 10 | 11 | @interface HFCircleImageView() 12 | 13 | @property (nonatomic, strong) CAShapeLayer *maskLayer; 14 | @property (nonatomic, strong) CAShapeLayer *boarderLayer; 15 | 16 | @end 17 | 18 | @implementation HFCircleImageView 19 | 20 | - (void)layoutSublayersOfLayer:(CALayer *)layer 21 | { 22 | [super layoutSublayersOfLayer:layer]; 23 | 24 | CGFloat centerX = CGRectGetMidX(self.bounds); 25 | CGFloat centerY = CGRectGetMidY(self.bounds); 26 | CGFloat width = CGRectGetWidth(self.frame); 27 | CGFloat height = CGRectGetHeight(self.frame); 28 | 29 | NSInteger cornerRadius = MIN(width, height)/2.0; 30 | 31 | if(CGSizeEqualToSize(_cornerSize, CGSizeZero)){ 32 | _cornerSize = CGSizeMake(cornerRadius, cornerRadius); 33 | }; 34 | 35 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(centerX-cornerRadius, centerY-cornerRadius, cornerRadius*2.0, cornerRadius*2.0) byRoundingCorners:UIRectCornerAllCorners cornerRadii:_cornerSize]; 36 | if(_boarderWidth > 0 && _boarderColor){ 37 | if(!self.boarderLayer.superlayer)[self.layer addSublayer:self.boarderLayer]; 38 | self.boarderLayer.lineWidth = _boarderWidth; 39 | self.boarderLayer.path = circlePath.CGPath; 40 | self.boarderLayer.strokeColor = _boarderColor.CGColor; 41 | } 42 | self.maskLayer.path = circlePath.CGPath; 43 | 44 | self.layer.mask = self.maskLayer; 45 | } 46 | 47 | - (void)p_updateCircleMask 48 | { 49 | CGFloat width = CGRectGetWidth(self.frame); 50 | CGFloat height = CGRectGetHeight(self.frame); 51 | 52 | CGFloat centerX = CGRectGetMidX(self.bounds); 53 | CGFloat centerY = CGRectGetMidY(self.bounds); 54 | 55 | CGFloat corner = MIN(width, height)/2.0; 56 | 57 | if(CGSizeEqualToSize(_cornerSize, CGSizeZero)){ 58 | _cornerSize = CGSizeMake(corner, corner); 59 | }; 60 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(centerX-corner, centerY-corner, corner*2.0, corner*2.0) byRoundingCorners:UIRectCornerAllCorners cornerRadii:_cornerSize]; 61 | 62 | self.maskLayer.path = circlePath.CGPath; 63 | 64 | self.layer.mask = self.maskLayer; 65 | } 66 | 67 | #pragma mark-setter/getter 68 | - (CAShapeLayer *)maskLayer 69 | { 70 | if(!_maskLayer){ 71 | _maskLayer = [CAShapeLayer layer]; 72 | _maskLayer.contentsScale = [[UIScreen mainScreen] scale]; 73 | } 74 | return _maskLayer; 75 | } 76 | 77 | - (CAShapeLayer *)boarderLayer 78 | { 79 | if(!_boarderLayer){ 80 | _boarderLayer = [CAShapeLayer layer]; 81 | _boarderLayer.fillColor = [UIColor clearColor].CGColor; 82 | } 83 | return _boarderLayer; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HFGradientButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFGradientButton.h 3 | // Tool 4 | // 5 | // Created by 夜站 on 2018/6/22. 6 | // Copyright © 2018年 jackson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HFGradientButton : UIButton 12 | 13 | ///渐变色设置,colors 颜色数组,元素为CGColor类型,startPoint、endPoint的心x,y都是为0-1,locations为0-1的NSNumber类型的数据,用于区分渐变色的截止点 14 | - (void)buildBtnLayerColorWithColors:(NSArray *)colors 15 | startPoint:(CGPoint)startPoint 16 | endPoint:(CGPoint)endPoint 17 | locations:(NSArray *)loacations; 18 | 19 | ///构造水平渐变 20 | - (void)buildHorizBtnColorWithColors:(NSArray *)colors; 21 | 22 | ///构造垂直渐变 23 | - (void)buildVerticalBtnColorWithColors:(NSArray *)colors; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HFGradientButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // HFGradientButton.m 3 | // Tool 4 | // 5 | // Created by 夜站 on 2018/6/22. 6 | // Copyright © 2018年 jackson. All rights reserved. 7 | // 8 | 9 | #import "HFGradientButton.h" 10 | 11 | @implementation HFGradientButton 12 | 13 | + (Class)layerClass 14 | { 15 | return [CAGradientLayer class]; 16 | } 17 | 18 | - (void)buildBtnLayerColorWithColors:(NSArray *)colors startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint locations:(NSArray *)loacations 19 | { 20 | CAGradientLayer *btnLayer = (CAGradientLayer *)self.layer; 21 | btnLayer.colors = colors; 22 | btnLayer.startPoint = startPoint; 23 | btnLayer.endPoint = endPoint; 24 | btnLayer.locations = loacations; 25 | } 26 | 27 | - (void)buildHorizBtnColorWithColors:(NSArray *)colors 28 | { 29 | [self buildBtnLayerColorWithColors:colors startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0) locations:@[@0,@1]]; 30 | } 31 | 32 | - (void)buildVerticalBtnColorWithColors:(NSArray *)colors 33 | { 34 | [self buildBtnLayerColorWithColors:colors startPoint:CGPointMake(0, 0) endPoint:CGPointMake(0, 1) locations:@[@0,@1]]; 35 | } 36 | 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HFNumberTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZNumberTextField.m 3 | // NightStation 4 | // 5 | // Created by jackson on 2018/1/12. 6 | // Copyright © 2018年 hufei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HFNumberTextField : UITextField 12 | 13 | @property (nonatomic, copy)void(^doneBlock)(); 14 | 15 | //右下角完成按钮的标题 16 | @property (nonatomic, copy) NSString *doneBtnTitle; 17 | 18 | /** 19 | 点击完成按钮(左下角) 是否自动收起键盘,默认YES收起 20 | */ 21 | @property (nonatomic, assign) BOOL hideKeyboard; 22 | 23 | @end 24 | 25 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HFNumberTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZNumberTextField.m 3 | // NightStation 4 | // 5 | // Created by jackson on 2018/1/12. 6 | // Copyright © 2018年 hufei. All rights reserved. 7 | // 8 | 9 | #import "HFNumberTextField.h" 10 | 11 | #define kScreen_Width [UIScreen mainScreen].bounds.size.width 12 | #define kScreen_Height [UIScreen mainScreen].bounds.size.height 13 | #define isiPhoneX (kScreen_Height == 812 && kScreen_Width == 375) 14 | 15 | @interface HFNumberTextField() 16 | 17 | //这个button只做展示,添加在键盘上的按钮触发的事件会被忽略, 18 | @property (nonatomic, strong) UIButton *doneBtn; 19 | 20 | @property (nonatomic, strong) UIButton *trueDoneBtn; 21 | 22 | @end 23 | 24 | @implementation HFNumberTextField 25 | 26 | #pragma mark- life circle 27 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 28 | { 29 | self = [super initWithCoder:aDecoder]; 30 | if(self){ 31 | [self p_configTF]; 32 | } 33 | return self; 34 | } 35 | 36 | - (instancetype)init 37 | { 38 | return [self initWithFrame:CGRectZero]; 39 | } 40 | 41 | - (instancetype)initWithFrame:(CGRect)frame 42 | { 43 | self = [super initWithFrame:frame]; 44 | if(self){ 45 | [self p_configTF]; 46 | } 47 | return self; 48 | } 49 | 50 | - (void)dealloc 51 | { 52 | _doneBtn = nil; 53 | _trueDoneBtn = nil; 54 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 55 | } 56 | 57 | #pragma mark- private method 58 | - (void)p_configTF 59 | { 60 | self.keyboardType = UIKeyboardTypeNumberPad; 61 | self.hideKeyboard = YES; 62 | 63 | [self addTarget:self action:@selector(_willbeginEdit) forControlEvents:UIControlEventEditingDidBegin]; 64 | [self addTarget:self action:@selector(_didEndEdit) forControlEvents:UIControlEventEditingDidEnd]; 65 | 66 | //注册键盘弹起通知 67 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 68 | } 69 | 70 | #pragma mark- action 71 | - (void)_willbeginEdit 72 | { 73 | self.doneBtn.hidden = NO; 74 | self.trueDoneBtn.hidden = NO; 75 | } 76 | 77 | - (void)_didEndEdit 78 | { 79 | self.doneBtn.hidden = YES; 80 | self.trueDoneBtn.hidden = YES; 81 | } 82 | 83 | - (void)keyboardWillShow:(NSNotification *)noti 84 | { 85 | if(![self isUseExtensionInputMode]){ 86 | [self configBtnsWithNoti:noti]; 87 | } 88 | } 89 | 90 | - (void)configBtnsWithNoti:(NSNotification *)noti 91 | { 92 | if(!self.doneBtn.superview){ 93 | NSArray *windows = [UIApplication sharedApplication].windows; 94 | UIWindow *keyboardWindow = nil; 95 | for (UIWindow *window in windows) { 96 | if([window isKindOfClass:NSClassFromString(@"UIRemoteKeyboardWindow")]){ 97 | keyboardWindow = window; 98 | } 99 | } 100 | if(keyboardWindow){ 101 | NSArray *views = keyboardWindow.rootViewController.view.subviews; 102 | UIView *keyboardView = views.lastObject; 103 | [self performSelector:@selector(addBtns:) withObject:@[keyboardView,keyboardWindow] afterDelay:0.01f]; 104 | } 105 | } 106 | CGRect keyboardFrame = [noti.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; 107 | CGFloat iphoneX_Space = isiPhoneX?75.f:0.f;//iphoneX 的键盘高度比其他的高出了75 108 | CGFloat btnWidth = keyboardFrame.size.width / 3.0; 109 | CGFloat btnHeight = (keyboardFrame.size.height - iphoneX_Space) / 4.0; 110 | self.doneBtn.frame = CGRectMake(0, btnHeight*3.0, btnWidth, btnHeight); 111 | self.trueDoneBtn.frame = CGRectMake(0, keyboardFrame.origin.y + btnHeight*3.0, btnWidth, btnHeight); 112 | } 113 | 114 | - (void)addBtns:(NSArray *)superViews { 115 | if(!_doneBtn.superview)[superViews.firstObject addSubview:_doneBtn]; 116 | if(!_trueDoneBtn.superview)[superViews.lastObject addSubview:_trueDoneBtn]; 117 | } 118 | 119 | - (void)_doneBtnAction 120 | { 121 | if(_hideKeyboard)[self resignFirstResponder]; 122 | if(_doneBlock){ 123 | _doneBlock(); 124 | } 125 | } 126 | 127 | #pragma mark- private method 128 | //判断是否有第三方输入法 129 | - (BOOL)isUseExtensionInputMode 130 | { 131 | UITextInputMode *inputMode = [self textInputMode]; 132 | return [NSStringFromClass([inputMode class]) isEqualToString:@"UIKeyboardExtensionInputMode"]; 133 | } 134 | 135 | #pragma mark- setter/getter 136 | - (void)setDoneBtnTitle:(NSString *)doneBtnTitle 137 | { 138 | _doneBtnTitle = doneBtnTitle; 139 | [_doneBtn setTitle:doneBtnTitle forState:UIControlStateNormal]; 140 | } 141 | 142 | - (UIButton *)doneBtn 143 | { 144 | if(!_doneBtn){ 145 | _doneBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 146 | [_doneBtn setTitle:@"完成" forState:UIControlStateNormal]; 147 | _trueDoneBtn.frame = CGRectMake(0, kScreen_Height, 200, 44); 148 | [_doneBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 149 | _doneBtn.hidden = YES; 150 | } 151 | return _doneBtn; 152 | } 153 | 154 | - (UIButton *)trueDoneBtn 155 | { 156 | if(!_trueDoneBtn){ 157 | _trueDoneBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 158 | _trueDoneBtn.backgroundColor = [UIColor clearColor]; 159 | _trueDoneBtn.frame = CGRectMake(0, kScreen_Height, 200, 44); 160 | _trueDoneBtn.hidden = YES; 161 | [_trueDoneBtn addTarget:self action:@selector(_doneBtnAction) forControlEvents:UIControlEventTouchUpInside]; 162 | } 163 | return _trueDoneBtn; 164 | } 165 | 166 | @end 167 | 168 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HFUIFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTUIFactory.h 3 | // WALNUTT 4 | // 5 | // Created by WalnutTech on 2018/9/4. 6 | // Copyright © 2018年 WalnutTech. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @interface HTUIFactory : NSObject 14 | 15 | #pragma mark- label 16 | + (UILabel *)labelWithFont:(UIFont *)font textColor:(UIColor *)textColor; 17 | 18 | + (UILabel *)labelWithFont:(UIFont *)font textColor:(UIColor *)textColor text:(NSString *)text; 19 | 20 | + (UILabel *)centerAlignmentLabelWithFont:(UIFont *)font textColor:(UIColor *)textColor text:(NSString *)text; 21 | 22 | #pragma mark- button 23 | + (UIButton *)buttonWithImageStrForNormal:(NSString *)imageStr 24 | imageStrForSelected:(NSString *)imageStrForSelected 25 | target:(id)target 26 | action:(SEL)action; 27 | 28 | + (UIButton *)buttonWithImageStrForNormal:(NSString *)imageStr 29 | target:(id)target 30 | action:(SEL)action; 31 | 32 | + (UIButton *)buttonWithTitleForNormal:(NSString *)title 33 | textColor:(UIColor *)textColor 34 | font:(UIFont *)font 35 | target:(id)target 36 | action:(SEL)action; 37 | 38 | + (UIButton *)buttonWithTitle:(NSString *)title 39 | textColorForNormal:(UIColor *)normalColor 40 | textColorForSelected:(UIColor *)selectedColor 41 | target:(id)target 42 | action:(SEL)action; 43 | 44 | 45 | + (UIButton *)buttonWithImageName:(NSString *)imageName 46 | title:(NSString *)title 47 | textColor:(UIColor *)textColor 48 | font:(UIFont *)font 49 | titleLeftSpace:(CGFloat)space 50 | target:(id)target 51 | action:(SEL)action; 52 | 53 | + (UIButton *)systemTypeButtonWithImageStrForNormal:(NSString *)imageStr 54 | imageStrForSelected:(NSString *)imageStrForSelected 55 | target:(id)target 56 | action:(SEL)action; 57 | 58 | #pragma mark- view 59 | + (UIView *)viewForBackgroundColor:(UIColor *)backgroundColor frame:(CGRect)frame; 60 | 61 | + (UIView *)viewForBackgroundColor:(UIColor *)backgroundColor; 62 | 63 | #pragma mark- tableView 64 | + (UITableView *)tableViewWithTableStyle:(UITableViewStyle )tableStyle 65 | cellClass:(Class )cellClass 66 | identifier:(NSString *)identifier 67 | delegate:(id)delegate 68 | dataSource:(id)dataSource; 69 | 70 | + (UITableView *)tableViewWithTableStyle:(UITableViewStyle )tableStyle 71 | cellNIBName:(NSString *)cellNIBName 72 | identifier:(NSString *)identifier 73 | delegate:(id)delegate 74 | dataSource:(id)dataSource; 75 | 76 | #pragma mark- imageView 77 | + (UIImageView *)imageViewForAspectFill; 78 | + (UIImageView *)imageViewWithImageName:(NSString *)imageName; 79 | + (UIImageView *)cellIndicatorImageView; 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HTDateSelectedComponent.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTDateSelectedComponent.h 3 | // WALNUTT 4 | // 5 | // Created by 胡斐 on 2019/8/5. 6 | // Copyright © 2019 WalnutTech. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef void(^SelectedDateBlcok)(NSString *dateStr); 14 | 15 | @interface HTDateSelectedComponent : UIView 16 | 17 | @property (nonatomic, copy) SelectedDateBlcok selectedBlock; 18 | @property (nonatomic, copy) NSString *dateFormatStr; 19 | 20 | - (instancetype)initWithDateFormatter:(NSString *)dateFormatter 21 | selectedDateBlock:(nullable SelectedDateBlcok) selectedBlock; 22 | 23 | - (void)show; 24 | - (void)showToView:(UIView *)targetView; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/HTDateSelectedComponent.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTDateSelectedComponent.m 3 | // WALNUTT 4 | // 5 | // Created by 胡斐 on 2019/8/5. 6 | // Copyright © 2019 WalnutTech. All rights reserved. 7 | // 8 | 9 | #import "HTDateSelectedComponent.h" 10 | 11 | @interface HTDateSelectedComponent() 12 | 13 | @property (nonatomic, strong) NSDateFormatter *dateFormatter; 14 | 15 | @property (nonatomic, strong) UIButton *cancelBtn; 16 | @property (nonatomic, strong) UIButton *doneBtn; 17 | 18 | @property (nonatomic, strong) UIView *contentView; 19 | @property (nonatomic, strong) UIDatePicker *datePicker; 20 | 21 | 22 | @end 23 | 24 | @implementation HTDateSelectedComponent 25 | 26 | - (instancetype)initWithDateFormatter:(NSString *)dateFormatter 27 | selectedDateBlock:(SelectedDateBlcok) selectedBlock 28 | { 29 | if(self = [super initWithFrame:[UIScreen mainScreen].bounds]){ 30 | _selectedBlock = selectedBlock; 31 | _dateFormatStr = dateFormatter; 32 | [self _configSubView]; 33 | } 34 | return self; 35 | } 36 | 37 | - (instancetype)initWithFrame:(CGRect)frame 38 | { 39 | return [self initWithDateFormatter:@"YYYY-MM-dd" 40 | selectedDateBlock:nil]; 41 | } 42 | 43 | #pragma mark- action 44 | - (void)_cancelBtnAction 45 | { 46 | [self dismiss]; 47 | } 48 | 49 | - (void)_doneBtnAction 50 | { 51 | if(!_dateFormatStr)_dateFormatStr = @"YYYY-MM-dd"; 52 | 53 | self.dateFormatter.dateFormat = _dateFormatStr; 54 | NSDate *selectedDate = _datePicker.date; 55 | 56 | NSString *dateStr = [self.dateFormatter stringFromDate:selectedDate]; 57 | if(_selectedBlock)_selectedBlock(dateStr); 58 | [self dismiss]; 59 | } 60 | 61 | #pragma mark- public method 62 | - (void)show 63 | { 64 | [self showToView:[UIApplication sharedApplication].keyWindow]; 65 | } 66 | 67 | - (void)showToView:(UIView *)targetView 68 | { 69 | if(!targetView)targetView = [UIApplication sharedApplication].keyWindow; 70 | 71 | [targetView addSubview:self]; 72 | [self mas_makeConstraints:^(MASConstraintMaker *make) { 73 | make.edges.equalTo(targetView); 74 | }]; 75 | 76 | [self setNeedsLayout]; 77 | [self layoutIfNeeded]; 78 | 79 | self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0]; 80 | [_contentView mas_remakeConstraints:^(MASConstraintMaker *make) { 81 | make.bottom.equalTo(self.mas_bottom); 82 | make.left.right.equalTo(self); 83 | }]; 84 | [UIView animateWithDuration:0.15 animations:^{ 85 | self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.25]; 86 | [self setNeedsLayout]; 87 | [self layoutIfNeeded]; 88 | }]; 89 | } 90 | 91 | - (void)dismiss 92 | { 93 | [_contentView mas_remakeConstraints:^(MASConstraintMaker *make) { 94 | make.top.equalTo(self.mas_bottom); 95 | make.left.right.equalTo(self); 96 | }]; 97 | [UIView animateWithDuration:0.15 animations:^{ 98 | [self setNeedsLayout]; 99 | [self layoutIfNeeded]; 100 | self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0]; 101 | } completion:^(BOOL finished) { 102 | [self removeFromSuperview]; 103 | }]; 104 | } 105 | 106 | #pragma mark- private method 107 | - (void)_configSubView 108 | { 109 | [self addSubview:self.contentView]; 110 | [self.contentView addSubview:self.cancelBtn]; 111 | [self.contentView addSubview:self.doneBtn]; 112 | [self.contentView addSubview:self.datePicker]; 113 | 114 | [_contentView mas_makeConstraints:^(MASConstraintMaker *make) { 115 | make.left.right.equalTo(self); 116 | make.top.equalTo(self.mas_bottom); 117 | }]; 118 | 119 | [_cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) { 120 | make.width.mas_equalTo(42); 121 | make.height.mas_equalTo(47); 122 | make.left.equalTo(_contentView).offset(13); 123 | make.top.equalTo(_contentView); 124 | }]; 125 | [_doneBtn mas_makeConstraints:^(MASConstraintMaker *make) { 126 | make.width.mas_equalTo(42); 127 | make.height.mas_equalTo(47); 128 | make.right.equalTo(_contentView).offset(-13); 129 | make.top.equalTo(_contentView); 130 | }]; 131 | [_datePicker mas_makeConstraints:^(MASConstraintMaker *make) { 132 | make.top.equalTo(_doneBtn.mas_bottom); 133 | make.bottom.left.right.equalTo(_contentView); 134 | make.height.mas_equalTo(190*_MAIN_SCALE_IPHONE6); 135 | }]; 136 | } 137 | 138 | #pragma mark- setter/getter 139 | - (UIButton *)cancelBtn 140 | { 141 | if(!_cancelBtn){ 142 | _cancelBtn = [HTUIFactory buttonWithTitleForNormal:NSLocalizedString(@"app_cancel", nil) textColor:UIHEXCOLOR(0x9B9B9B) font:HTSYSTEMFONT(14.0) target:self action:@selector(_cancelBtnAction)]; 143 | } 144 | return _cancelBtn; 145 | } 146 | 147 | - (UIButton *)doneBtn 148 | { 149 | if(!_doneBtn){ 150 | _doneBtn = [HTUIFactory buttonWithTitleForNormal:NSLocalizedString(@"app_OK", nil) textColor:UIHEXCOLOR(0x303030) font:HTSYSTEMFONT(14.0) target:self action:@selector(_doneBtnAction)]; 151 | } 152 | return _doneBtn; 153 | } 154 | 155 | - (UIDatePicker *)datePicker 156 | { 157 | if(!_datePicker){ 158 | _datePicker = [[UIDatePicker alloc] init]; 159 | _datePicker.date = [NSDate date]; 160 | _datePicker.datePickerMode = UIDatePickerModeDate; 161 | _datePicker.maximumDate = [NSDate date]; 162 | _datePicker.minimumDate = [NSDate dateWithTimeIntervalSince1970:10*365*24*60*60]; 163 | } 164 | return _datePicker; 165 | } 166 | 167 | - (NSDateFormatter *)dateFormatter 168 | { 169 | if(!_dateFormatter){ 170 | _dateFormatter = [[NSDateFormatter alloc] init]; 171 | } 172 | return _dateFormatter; 173 | } 174 | 175 | - (UIView *)contentView 176 | { 177 | if(!_contentView){ 178 | _contentView = [HTUIFactory viewForBackgroundColor:UIHEXCOLOR(0xF6F6F6)]; 179 | } 180 | return _contentView; 181 | } 182 | 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/YZVerifyButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZVerifyButton.h 3 | // NightStation 4 | // 5 | // Created by 夜站 on 2018/1/12. 6 | // Copyright © 2018年 liufy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YZVerifyButton : UIButton 12 | 13 | -(void)openCountdown; 14 | @end 15 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/YZVerifyButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZVerifyButton.m 3 | // NightStation 4 | // 5 | // Created by 夜站 on 2018/1/12. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import "YZVerifyButton.h" 10 | 11 | #define kButtonDisaleTitleColor [UIColor colorWithRed:157/255.0 green:157/255.0 blue:157/255.0 alpha:1] 12 | #define kButtonNormalTitleColor [UIColor darkGrayColor] 13 | #define kDuration 59 14 | 15 | @implementation YZVerifyButton 16 | 17 | - (void)awakeFromNib 18 | { 19 | [super awakeFromNib]; 20 | [self refreshUI]; 21 | } 22 | 23 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 24 | { 25 | if(self = [super initWithCoder:aDecoder]){ 26 | [self p_initUI]; 27 | } 28 | return self; 29 | } 30 | 31 | - (instancetype)initWithFrame:(CGRect)frame 32 | { 33 | self = [super initWithFrame:frame]; 34 | if(self){ 35 | [self p_initUI]; 36 | [self refreshUI]; 37 | } 38 | return self; 39 | } 40 | 41 | - (void)p_initUI 42 | { 43 | [self setTitleColor:kButtonDisaleTitleColor forState:UIControlStateDisabled]; 44 | [self setTitleColor:kButtonNormalTitleColor forState:UIControlStateNormal]; 45 | } 46 | 47 | - (void)refreshUI 48 | { 49 | if(_timer)dispatch_source_cancel(_timer); 50 | dispatch_async(dispatch_get_main_queue(), ^{ 51 | 52 | //设置按钮的样式 53 | [self setTitle:@"获取验证码" forState:UIControlStateNormal]; 54 | self.enabled = YES; 55 | }); 56 | } 57 | 58 | dispatch_source_t _timer ; 59 | // 开启倒计时效果 60 | -(void)openCountdown{ 61 | 62 | __block NSInteger time = kDuration; //倒计时时间 63 | 64 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 65 | _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); 66 | 67 | dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行 68 | 69 | dispatch_source_set_event_handler(_timer, ^{ 70 | 71 | if(time <= 0){ //倒计时结束,关闭 72 | [self refreshUI]; 73 | }else{ 74 | 75 | int seconds = time % 60; 76 | dispatch_async(dispatch_get_main_queue(), ^{ 77 | 78 | //设置按钮显示读秒效果 79 | [self setTitle:[NSString stringWithFormat:@"%d秒后重试", seconds] forState:UIControlStateNormal]; 80 | 81 | self.enabled = NO; 82 | }); 83 | time--; 84 | } 85 | }); 86 | dispatch_resume(_timer); 87 | } 88 | 89 | @end 90 | 91 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/sheet/FHAlertAction.h: -------------------------------------------------------------------------------- 1 | // 2 | // FHAlertAction.h 3 | // demo 4 | // 5 | // Created by 胡斐 on 2018/8/6. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | typedef NS_ENUM(NSInteger, FHAlertActionStyle) { 13 | FHAlertActionStyleDefault = 0, 14 | FHAlertActionStyleCancel, 15 | FHAlertActionStyleDestructive 16 | }; 17 | 18 | @interface FHAlertAction : NSObject 19 | 20 | @property (nullable, nonatomic, readonly) NSString *title; 21 | @property (nonatomic, readonly) FHAlertActionStyle style; 22 | @property (nonatomic, readonly) CGFloat fontSize; 23 | @property (nonatomic, readonly) UIColor *textColor; 24 | 25 | ///系统默认样式 26 | + (instancetype)actionWithTitle:(nullable NSString *)title style:(FHAlertActionStyle)style handler:(void (^ __nullable)(FHAlertAction *action))handler; 27 | 28 | ///高度自定义点击的样式 29 | + (instancetype)actionWithTitle:(nullable NSString *)title fontSize:(CGFloat )fontSize textColor:(UIColor *)textColor style:(FHAlertActionStyle)style handler:(void (^ __nullable)(FHAlertAction *action))handler; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/sheet/FHAlertAction.m: -------------------------------------------------------------------------------- 1 | // 2 | // FHAlertAction.m 3 | // demo 4 | // 5 | // Created by 胡斐 on 2018/8/6. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import "FHAlertAction.h" 10 | 11 | @interface FHAlertAction() 12 | 13 | @property (nullable, nonatomic, ) NSString *title; 14 | @property (nonatomic ) FHAlertActionStyle style; 15 | @property (nonatomic ) CGFloat fontSize; 16 | @property (nonatomic ) UIColor *textColor; 17 | @property (nonatomic, copy) void(^handler)(FHAlertAction *action); 18 | 19 | @end 20 | 21 | @implementation FHAlertAction 22 | 23 | + (instancetype)actionWithTitle:(nullable NSString *)title style:(FHAlertActionStyle)style handler:(void (^ __nullable)(FHAlertAction *action))handler{ 24 | return [self actionWithTitle:title fontSize:14 textColor:[UIColor blackColor] style:style handler:handler]; 25 | } 26 | 27 | + (instancetype)actionWithTitle:(nullable NSString *)title fontSize:(CGFloat )fontSize textColor:(UIColor *)textColor style:(FHAlertActionStyle)style handler:(void (^ __nullable)(FHAlertAction *action))handler 28 | { 29 | FHAlertAction *action = [[FHAlertAction alloc] init]; 30 | if (!title) { 31 | assert("must have a title"); 32 | } 33 | action.title = title; 34 | action.fontSize = fontSize ? fontSize : 14; 35 | action.textColor = textColor ? textColor : [UIColor blackColor]; 36 | action.style = style ? style : FHAlertActionStyleDefault; 37 | action.handler = handler; 38 | 39 | return action; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/sheet/FHAlertHeaderView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FHAlertHeaderView.h 3 | // demo 4 | // 5 | // Created by 胡斐 on 2018/8/6. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FHAlertHeaderView : UIView 12 | 13 | @property (nonatomic, strong) UILabel *titleLb; 14 | 15 | @property (nonatomic, strong) UILabel *messageLb; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/sheet/FHAlertHeaderView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FHAlertHeaderView.m 3 | // demo 4 | // 5 | // Created by 胡斐 on 2018/8/6. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import "FHAlertHeaderView.h" 10 | #import "Masonry.h" 11 | 12 | @implementation FHAlertHeaderView 13 | 14 | - (instancetype)init 15 | { 16 | return [self initWithFrame:CGRectZero]; 17 | } 18 | 19 | - (instancetype)initWithFrame:(CGRect)frame 20 | { 21 | if(self = [super initWithFrame:frame]){ 22 | 23 | _titleLb = [[UILabel alloc] init]; 24 | _titleLb.textAlignment = NSTextAlignmentCenter; 25 | _messageLb = [[UILabel alloc] init]; 26 | _messageLb.textAlignment = NSTextAlignmentCenter; 27 | [self addSubview:_titleLb]; 28 | [self addSubview:_messageLb]; 29 | 30 | [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) { 31 | make.top.equalTo(self).offset(10); 32 | make.left.right.equalTo(self); 33 | make.bottom.equalTo(self->_messageLb.mas_top).offset(-10); 34 | }]; 35 | [_messageLb mas_makeConstraints:^(MASConstraintMaker *make) { 36 | make.bottom.equalTo(self).offset(-10); 37 | make.left.right.equalTo(self); 38 | make.top.equalTo(self.titleLb.mas_bottom).offset(10); 39 | }]; 40 | 41 | } 42 | return self; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/sheet/FHAlertSheetView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FHAlertSheetView.h 3 | // demo 4 | // 5 | // Created by 胡斐 on 2018/8/7. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FHAlertAction.h" 11 | 12 | typedef NS_ENUM(NSInteger, FHAlertControllerStyle) { 13 | FHAlertControllerStyleActionSheet = 0, 14 | FHAlertControllerStyleAlert 15 | } NS_ENUM_AVAILABLE_IOS(8_0); 16 | 17 | @interface FHAlertSheetView : UIView 18 | 19 | @property (nonatomic, strong, readonly)NSMutableArray *actions; 20 | 21 | ///点击按钮的高度 22 | @property (nonatomic, assign) CGFloat itemHeight UI_APPEARANCE_SELECTOR; 23 | 24 | @property (nonatomic, strong) UIFont *itemFont UI_APPEARANCE_SELECTOR; 25 | 26 | @property (nonatomic, assign) CGFloat cornerRadius UI_APPEARANCE_SELECTOR; 27 | 28 | @property (nonatomic, assign) CGFloat offsetX UI_APPEARANCE_SELECTOR; 29 | 30 | ///底部间距 31 | @property (nonatomic, assign) CGFloat offsetY UI_APPEARANCE_SELECTOR; 32 | 33 | @property (nonatomic, assign) CGFloat animationDuration UI_APPEARANCE_SELECTOR; 34 | 35 | @property (nonatomic, strong) UIColor *seperatorColor UI_APPEARANCE_SELECTOR; 36 | 37 | @property (nonatomic, strong) UIColor *destructiveColor UI_APPEARANCE_SELECTOR; 38 | 39 | @property (nonatomic, assign) CGFloat space UI_APPEARANCE_SELECTOR; 40 | 41 | 42 | + (instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(FHAlertControllerStyle)preferredStyle; 43 | 44 | - (void)addAction:(FHAlertAction *)action; 45 | 46 | ///展示在window上 47 | - (void)show; 48 | ///展示在哪个视图上 49 | - (void)showInView:(UIView *)view; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/图片裁剪/FHClipImageViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FHClipImageViewController.h 3 | // Calendar 4 | // 5 | // Created by 胡斐 on 2018/4/22. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FHClipImageViewController : UIViewController 12 | 13 | @property (nonatomic, copy) void(^clipImageBlock)(UIImage *result); 14 | 15 | - (instancetype)initWithTargetImage:(UIImage *)targetImage maskFrame:(CGRect)maskFrame clipBlock:(void(^)(UIImage *result))clipImageBlock; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/图片裁剪/FHClipImageViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FHClipImageViewController.m 3 | // Calendar 4 | // 5 | // Created by 胡斐 on 2018/4/22. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #define KSCREEN_W ([UIScreen mainScreen].bounds.size.width) 10 | #define KSCREEN_H ([UIScreen mainScreen].bounds.size.height) 11 | 12 | #import "FHClipImageViewController.h" 13 | #import "MaskView.h" 14 | 15 | @interface FHClipImageViewController () 16 | 17 | @property (strong, nonatomic) UIScrollView *scrollView; 18 | 19 | @property (strong, nonatomic) UIImageView *imageView; 20 | @property (strong, nonatomic) MaskView *maskView; 21 | 22 | @property (nonatomic, strong) UIImage *targetImage; 23 | @property (nonatomic, assign)CGRect maskFrame; 24 | 25 | @end 26 | 27 | @implementation FHClipImageViewController 28 | 29 | #pragma mark- life circle 30 | - (instancetype)init 31 | { 32 | NSAssert(YES, @"请用initWithTargetImage: maskFrame: clipBlock:来创建"); 33 | return [self initWithTargetImage:nil maskFrame:CGRectZero clipBlock:nil]; 34 | } 35 | 36 | - (instancetype)initWithTargetImage:(UIImage *)targetImage maskFrame:(CGRect)maskFrame clipBlock:(void(^)(UIImage *result))clipImageBlock 37 | { 38 | if(self = [super init]){ 39 | _targetImage = targetImage; 40 | _maskFrame = maskFrame; 41 | _clipImageBlock = clipImageBlock; 42 | } 43 | return self; 44 | } 45 | 46 | - (void)viewDidLoad { 47 | [super viewDidLoad]; 48 | [self p_setupUI]; 49 | } 50 | 51 | - (void)viewWillAppear:(BOOL)animated 52 | { 53 | [super viewWillAppear:animated]; 54 | self.navigationController.navigationBar.translucent = NO; 55 | 56 | _scrollView.frame = _maskFrame; 57 | _maskView.frame = self.view.bounds; 58 | 59 | 60 | } 61 | 62 | #pragma mark- public method 63 | - (void)_getClipImage 64 | { 65 | // 创建一个context 66 | UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, NO, 1.); 67 | //把当前的全部画面导入到栈顶context中并进行渲染 68 | [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 69 | // 从当前context中创建一个新图片 70 | UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); 71 | // 使当前的context出堆栈 72 | 73 | CGImageRef imgRef = CGImageCreateWithImageInRect(img.CGImage, _maskView.maskFrame); 74 | //获取到的图片 75 | img = [UIImage imageWithCGImage:imgRef]; 76 | CGImageRelease(imgRef); 77 | UIGraphicsEndImageContext(); 78 | 79 | if(_clipImageBlock)(_clipImageBlock(img)); 80 | 81 | [self.navigationController popViewControllerAnimated:YES]; 82 | } 83 | 84 | #pragma mark- private method 85 | - (void)p_setupUI 86 | { 87 | self.view.clipsToBounds = YES; 88 | [self.view addSubview:self.scrollView]; 89 | [self.scrollView addSubview:self.imageView]; 90 | [self.view addSubview:self.maskView]; 91 | self.scrollView.delegate = self; 92 | 93 | if (@available(iOS 11.0, *)) { 94 | _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; 95 | } else { 96 | self.automaticallyAdjustsScrollViewInsets = NO; 97 | } 98 | 99 | _scrollView.maximumZoomScale = 3.0; 100 | _scrollView.minimumZoomScale = 1.0; 101 | _scrollView.bounces = YES; 102 | 103 | CGFloat image_width = _targetImage.size.width; 104 | CGFloat image_height = _targetImage.size.height; 105 | 106 | NSInteger targetHeight = CGRectGetHeight(_maskFrame); 107 | NSInteger targetWidth = (targetHeight / image_height)*image_width; 108 | 109 | NSLog(@"look %ld , %ld",(long)targetWidth,(long)targetHeight); 110 | 111 | _imageView.frame = CGRectMake(0, 0, targetWidth, targetHeight); 112 | 113 | _imageView.image = [self imageResize:_targetImage andResizeTo:CGSizeMake(targetWidth, targetHeight)]; 114 | 115 | _scrollView.contentSize = CGSizeMake(targetWidth, targetHeight); 116 | 117 | _maskView.maskFrame = _maskFrame; 118 | 119 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(_getClipImage)]; 120 | } 121 | 122 | -(UIImage *)imageResize :(UIImage*)img andResizeTo:(CGSize)newSize 123 | { 124 | CGFloat scale = [[UIScreen mainScreen]scale]; 125 | 126 | UIGraphicsBeginImageContextWithOptions(newSize, NO, scale); 127 | [img drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; 128 | UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 129 | UIGraphicsEndImageContext(); 130 | return newImage; 131 | } 132 | 133 | #pragma mark- scrollViewDelegate 134 | - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 135 | { 136 | return _imageView; 137 | } 138 | 139 | #pragma mark- setter/getter 140 | - (MaskView *)maskView{ 141 | if(!_maskView){ 142 | _maskView = [[MaskView alloc] init]; 143 | } 144 | return _maskView; 145 | } 146 | 147 | - (UIImageView *)imageView 148 | { 149 | if(!_imageView){ 150 | _imageView = [[UIImageView alloc] init]; 151 | _imageView.contentMode = UIViewContentModeScaleAspectFill; 152 | } 153 | return _imageView; 154 | } 155 | 156 | - (UIScrollView *)scrollView 157 | { 158 | if(!_scrollView){ 159 | _scrollView = [[UIScrollView alloc] init]; 160 | _scrollView.showsVerticalScrollIndicator = NO; 161 | _scrollView.showsHorizontalScrollIndicator = NO; 162 | _scrollView.backgroundColor = [UIColor clearColor]; 163 | _scrollView.clipsToBounds = NO; 164 | } 165 | return _scrollView; 166 | } 167 | @end 168 | -------------------------------------------------------------------------------- /Tool/demo/Tool/class/图片裁剪/MaskView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MaskView.h 3 | // Calendar 4 | // 5 | // Created by 胡斐 on 2018/4/20. 6 | // Copyright © 2018年 胡斐. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MaskView : UIView 12 | 13 | @property (nonatomic, assign)CGRect maskFrame; 14 | 15 | //控制移动的上下左右的宽高 16 | @property (nonatomic, assign)CGFloat moveViewWidth; 17 | @property (nonatomic, assign)CGFloat moveViewHeight; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Tool/demo/Tool/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Tool 4 | // 5 | // Created by 胡斐 on 2018/5/19. 6 | // Copyright © 2018年 jackson. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tool/demo/podfile: -------------------------------------------------------------------------------- 1 | target 'Tool' do 2 | use_frameworks! 3 | pod 'SDWebImage', '~> 4.0' 4 | pod 'Masonry' 5 | end 6 | --------------------------------------------------------------------------------