├── .gitignore ├── Example ├── Podfile.lock ├── Pods │ ├── Headers │ │ ├── Private │ │ │ └── Masonry │ │ │ │ ├── MASCompositeConstraint.h │ │ │ │ ├── MASConstraint+Private.h │ │ │ │ ├── MASConstraint.h │ │ │ │ ├── MASConstraintMaker.h │ │ │ │ ├── MASLayoutConstraint.h │ │ │ │ ├── MASUtilities.h │ │ │ │ ├── MASViewAttribute.h │ │ │ │ ├── MASViewConstraint.h │ │ │ │ ├── Masonry.h │ │ │ │ ├── NSArray+MASAdditions.h │ │ │ │ ├── NSArray+MASShorthandAdditions.h │ │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ │ │ ├── View+MASAdditions.h │ │ │ │ ├── View+MASShorthandAdditions.h │ │ │ │ └── ViewController+MASAdditions.h │ │ └── Public │ │ │ └── Masonry │ │ │ ├── MASCompositeConstraint.h │ │ │ ├── MASConstraint+Private.h │ │ │ ├── MASConstraint.h │ │ │ ├── MASConstraintMaker.h │ │ │ ├── MASLayoutConstraint.h │ │ │ ├── MASUtilities.h │ │ │ ├── MASViewAttribute.h │ │ │ ├── MASViewConstraint.h │ │ │ ├── Masonry.h │ │ │ ├── NSArray+MASAdditions.h │ │ │ ├── NSArray+MASShorthandAdditions.h │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ │ ├── View+MASAdditions.h │ │ │ ├── View+MASShorthandAdditions.h │ │ │ └── ViewController+MASAdditions.h │ ├── Manifest.lock │ ├── Masonry │ │ ├── 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 │ │ │ ├── shevchenko.xcuserdatad │ │ │ └── xcschemes │ │ │ │ ├── Masonry.xcscheme │ │ │ │ ├── Pods-SKCalendarView.xcscheme │ │ │ │ └── xcschememanagement.plist │ │ │ └── xiangkuilin.xcuserdatad │ │ │ └── xcschemes │ │ │ ├── Masonry.xcscheme │ │ │ ├── Pods-SKCalendarView.xcscheme │ │ │ └── xcschememanagement.plist │ └── Target Support Files │ │ ├── Masonry │ │ ├── Masonry-dummy.m │ │ ├── Masonry-prefix.pch │ │ └── Masonry.xcconfig │ │ └── Pods-SKCalendarView │ │ ├── Pods-SKCalendarView-acknowledgements.markdown │ │ ├── Pods-SKCalendarView-acknowledgements.plist │ │ ├── Pods-SKCalendarView-dummy.m │ │ ├── Pods-SKCalendarView-frameworks.sh │ │ ├── Pods-SKCalendarView-resources.sh │ │ ├── Pods-SKCalendarView.debug.xcconfig │ │ └── Pods-SKCalendarView.release.xcconfig ├── SKCalendarView.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── shevchenko.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── shevchenko.xcuserdatad │ │ └── xcschemes │ │ │ ├── SKCalendarView.xcscheme │ │ │ └── xcschememanagement.plist │ │ └── xiangkuilin.xcuserdatad │ │ └── xcschemes │ │ ├── SKCalendarView.xcscheme │ │ └── xcschememanagement.plist ├── SKCalendarView.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ ├── shevchenko.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xiangkuilin.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist ├── SKCalendarView │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── new_loading10_400x400_@1x.imageset │ │ │ ├── Contents.json │ │ │ └── new_loading10_400x400_@1x.png │ │ └── new_loading25_400x400_@1x.imageset │ │ │ ├── Contents.json │ │ │ └── new_loading25_400x400_@1x.png │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── podfile ├── LICENSE ├── README.md ├── SKCalendarView.podspec └── Source └── SKCalendarView ├── Algorithm ├── SKCalendarManage.h └── SKCalendarManage.m ├── Animation ├── SKCalendarAnimationManage.h └── SKCalendarAnimationManage.m ├── Tool ├── SKConstant.h ├── SKDateSecurity.h └── SKDateSecurity.m └── View ├── SKCalendarCollectionViewCell.h ├── SKCalendarCollectionViewCell.m ├── SKCalendarView.h ├── SKCalendarView.m ├── SKWeekCollectionViewCell.h └── SKWeekCollectionViewCell.m /.gitignore: -------------------------------------------------------------------------------- 1 | #################################### 2 | ######## OS generated files ######## 3 | #################################### 4 | .DS_Store 5 | .DS_Store? 6 | *.swp 7 | ._* 8 | .Spotlight-V100 9 | .Trashes 10 | Icon? 11 | ehthumbs.db 12 | Thumbs.db 13 | #################################### 14 | ############# packages ############# 15 | #################################### 16 | *.7z 17 | *.dmg 18 | *.gz 19 | *.iso 20 | *.jar 21 | *.rar 22 | *.tar 23 | *.zip 24 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.0.2) 3 | 4 | DEPENDENCIES: 5 | - Masonry (~> 1.0.2) 6 | 7 | SPEC REPOS: 8 | https://github.com/cocoapods/specs.git: 9 | - Masonry 10 | 11 | SPEC CHECKSUMS: 12 | Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e 13 | 14 | PODFILE CHECKSUM: 92ae05c759660b24eaf4cfb0597b7a8c3c337231 15 | 16 | COCOAPODS: 1.6.0.beta.1 17 | -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.0.2) 3 | 4 | DEPENDENCIES: 5 | - Masonry (~> 1.0.2) 6 | 7 | SPEC REPOS: 8 | https://github.com/cocoapods/specs.git: 9 | - Masonry 10 | 11 | SPEC CHECKSUMS: 12 | Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e 13 | 14 | PODFILE CHECKSUM: 92ae05c759660b24eaf4cfb0597b7a8c3c337231 15 | 16 | COCOAPODS: 1.6.0.beta.1 17 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/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)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * Enables Constraints to be created with chainable syntax 13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint) 14 | * or a group of NSLayoutConstraints (MASComposisteConstraint) 15 | */ 16 | @interface MASConstraint : NSObject 17 | 18 | // Chaining Support 19 | 20 | /** 21 | * Modifies the NSLayoutConstraint constant, 22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 24 | */ 25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets; 26 | 27 | /** 28 | * Modifies the NSLayoutConstraint constant, 29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 31 | */ 32 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 38 | */ 39 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant 43 | */ 44 | - (MASConstraint * (^)(CGFloat offset))offset; 45 | 46 | /** 47 | * Modifies the NSLayoutConstraint constant based on a value type 48 | */ 49 | - (MASConstraint * (^)(NSValue *value))valueOffset; 50 | 51 | /** 52 | * Sets the NSLayoutConstraint multiplier property 53 | */ 54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 55 | 56 | /** 57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 58 | */ 59 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 60 | 61 | /** 62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 63 | */ 64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 65 | 66 | /** 67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 68 | */ 69 | - (MASConstraint * (^)())priorityLow; 70 | 71 | /** 72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 73 | */ 74 | - (MASConstraint * (^)())priorityMedium; 75 | 76 | /** 77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 78 | */ 79 | - (MASConstraint * (^)())priorityHigh; 80 | 81 | /** 82 | * Sets the constraint relation to NSLayoutRelationEqual 83 | * returns a block which accepts one of the following: 84 | * MASViewAttribute, UIView, NSValue, NSArray 85 | * see readme for more details. 86 | */ 87 | - (MASConstraint * (^)(id attr))equalTo; 88 | 89 | /** 90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 91 | * returns a block which accepts one of the following: 92 | * MASViewAttribute, UIView, NSValue, NSArray 93 | * see readme for more details. 94 | */ 95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 96 | 97 | /** 98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 99 | * returns a block which accepts one of the following: 100 | * MASViewAttribute, UIView, NSValue, NSArray 101 | * see readme for more details. 102 | */ 103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 104 | 105 | /** 106 | * Optional semantic property which has no effect but improves the readability of constraint 107 | */ 108 | - (MASConstraint *)with; 109 | 110 | /** 111 | * Optional semantic property which has no effect but improves the readability of constraint 112 | */ 113 | - (MASConstraint *)and; 114 | 115 | /** 116 | * Creates a new MASCompositeConstraint with the called attribute and reciever 117 | */ 118 | - (MASConstraint *)left; 119 | - (MASConstraint *)top; 120 | - (MASConstraint *)right; 121 | - (MASConstraint *)bottom; 122 | - (MASConstraint *)leading; 123 | - (MASConstraint *)trailing; 124 | - (MASConstraint *)width; 125 | - (MASConstraint *)height; 126 | - (MASConstraint *)centerX; 127 | - (MASConstraint *)centerY; 128 | - (MASConstraint *)baseline; 129 | 130 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 131 | 132 | - (MASConstraint *)firstBaseline; 133 | - (MASConstraint *)lastBaseline; 134 | 135 | #endif 136 | 137 | #if TARGET_OS_IPHONE || TARGET_OS_TV 138 | 139 | - (MASConstraint *)leftMargin; 140 | - (MASConstraint *)rightMargin; 141 | - (MASConstraint *)topMargin; 142 | - (MASConstraint *)bottomMargin; 143 | - (MASConstraint *)leadingMargin; 144 | - (MASConstraint *)trailingMargin; 145 | - (MASConstraint *)centerXWithinMargins; 146 | - (MASConstraint *)centerYWithinMargins; 147 | 148 | #endif 149 | 150 | 151 | /** 152 | * Sets the constraint debug name 153 | */ 154 | - (MASConstraint * (^)(id key))key; 155 | 156 | // NSLayoutConstraint constant Setters 157 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant, 161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 162 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 163 | */ 164 | - (void)setInsets:(MASEdgeInsets)insets; 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 170 | */ 171 | - (void)setSizeOffset:(CGSize)sizeOffset; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant, 175 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 176 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 177 | */ 178 | - (void)setCenterOffset:(CGPoint)centerOffset; 179 | 180 | /** 181 | * Modifies the NSLayoutConstraint constant 182 | */ 183 | - (void)setOffset:(CGFloat)offset; 184 | 185 | 186 | // NSLayoutConstraint Installation support 187 | 188 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 189 | /** 190 | * Whether or not to go through the animator proxy when modifying the constraint 191 | */ 192 | @property (nonatomic, copy, readonly) MASConstraint *animator; 193 | #endif 194 | 195 | /** 196 | * Activates an NSLayoutConstraint if it's supported by an OS. 197 | * Invokes install otherwise. 198 | */ 199 | - (void)activate; 200 | 201 | /** 202 | * Deactivates previously installed/activated NSLayoutConstraint. 203 | */ 204 | - (void)deactivate; 205 | 206 | /** 207 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 208 | */ 209 | - (void)install; 210 | 211 | /** 212 | * Removes previously installed NSLayoutConstraint 213 | */ 214 | - (void)uninstall; 215 | 216 | @end 217 | 218 | 219 | /** 220 | * Convenience auto-boxing macros for MASConstraint methods. 221 | * 222 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 223 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 224 | */ 225 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 226 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 227 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 228 | 229 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 230 | 231 | 232 | #ifdef MAS_SHORTHAND_GLOBALS 233 | 234 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 235 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 236 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 237 | 238 | #define offset(...) mas_offset(__VA_ARGS__) 239 | 240 | #endif 241 | 242 | 243 | @interface MASConstraint (AutoboxingSupport) 244 | 245 | /** 246 | * Aliases to corresponding relation methods (for shorthand macros) 247 | * Also needed to aid autocompletion 248 | */ 249 | - (MASConstraint * (^)(id attr))mas_equalTo; 250 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 251 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 252 | 253 | /** 254 | * A dummy method to aid autocompletion 255 | */ 256 | - (MASConstraint * (^)(id offset))mas_offset; 257 | 258 | @end 259 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 1/20/14. 6 | // 7 | 8 | #import "MASConstraint.h" 9 | #import "MASConstraint+Private.h" 10 | 11 | #define MASMethodNotImplemented() \ 12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \ 13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ 14 | userInfo:nil] 15 | 16 | @implementation MASConstraint 17 | 18 | #pragma mark - Init 19 | 20 | - (id)init { 21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); 22 | return [super init]; 23 | } 24 | 25 | #pragma mark - NSLayoutRelation proxies 26 | 27 | - (MASConstraint * (^)(id))equalTo { 28 | return ^id(id attribute) { 29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 30 | }; 31 | } 32 | 33 | - (MASConstraint * (^)(id))mas_equalTo { 34 | return ^id(id attribute) { 35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 36 | }; 37 | } 38 | 39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo { 40 | return ^id(id attribute) { 41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 42 | }; 43 | } 44 | 45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { 46 | return ^id(id attribute) { 47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 48 | }; 49 | } 50 | 51 | - (MASConstraint * (^)(id))lessThanOrEqualTo { 52 | return ^id(id attribute) { 53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 54 | }; 55 | } 56 | 57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { 58 | return ^id(id attribute) { 59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 60 | }; 61 | } 62 | 63 | #pragma mark - MASLayoutPriority proxies 64 | 65 | - (MASConstraint * (^)())priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)())priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)())priorityHigh { 80 | return ^id{ 81 | self.priority(MASLayoutPriorityDefaultHigh); 82 | return self; 83 | }; 84 | } 85 | 86 | #pragma mark - NSLayoutConstraint constant proxies 87 | 88 | - (MASConstraint * (^)(MASEdgeInsets))insets { 89 | return ^id(MASEdgeInsets insets){ 90 | self.insets = insets; 91 | return self; 92 | }; 93 | } 94 | 95 | - (MASConstraint * (^)(CGSize))sizeOffset { 96 | return ^id(CGSize offset) { 97 | self.sizeOffset = offset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGPoint))centerOffset { 103 | return ^id(CGPoint offset) { 104 | self.centerOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGFloat))offset { 110 | return ^id(CGFloat offset){ 111 | self.offset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(NSValue *value))valueOffset { 117 | return ^id(NSValue *offset) { 118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 119 | [self setLayoutConstantWithValue:offset]; 120 | return self; 121 | }; 122 | } 123 | 124 | - (MASConstraint * (^)(id offset))mas_offset { 125 | // Will never be called due to macro 126 | return nil; 127 | } 128 | 129 | #pragma mark - NSLayoutConstraint constant setter 130 | 131 | - (void)setLayoutConstantWithValue:(NSValue *)value { 132 | if ([value isKindOfClass:NSNumber.class]) { 133 | self.offset = [(NSNumber *)value doubleValue]; 134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 135 | CGPoint point; 136 | [value getValue:&point]; 137 | self.centerOffset = point; 138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 139 | CGSize size; 140 | [value getValue:&size]; 141 | self.sizeOffset = size; 142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 143 | MASEdgeInsets insets; 144 | [value getValue:&insets]; 145 | self.insets = insets; 146 | } else { 147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 148 | } 149 | } 150 | 151 | #pragma mark - Semantic properties 152 | 153 | - (MASConstraint *)with { 154 | return self; 155 | } 156 | 157 | - (MASConstraint *)and { 158 | return self; 159 | } 160 | 161 | #pragma mark - Chaining 162 | 163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 164 | MASMethodNotImplemented(); 165 | } 166 | 167 | - (MASConstraint *)left { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 169 | } 170 | 171 | - (MASConstraint *)top { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 173 | } 174 | 175 | - (MASConstraint *)right { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 177 | } 178 | 179 | - (MASConstraint *)bottom { 180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 181 | } 182 | 183 | - (MASConstraint *)leading { 184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 185 | } 186 | 187 | - (MASConstraint *)trailing { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 189 | } 190 | 191 | - (MASConstraint *)width { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 193 | } 194 | 195 | - (MASConstraint *)height { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 197 | } 198 | 199 | - (MASConstraint *)centerX { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 201 | } 202 | 203 | - (MASConstraint *)centerY { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 205 | } 206 | 207 | - (MASConstraint *)baseline { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 209 | } 210 | 211 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 212 | 213 | - (MASConstraint *)firstBaseline { 214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 215 | } 216 | - (MASConstraint *)lastBaseline { 217 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 218 | } 219 | 220 | #endif 221 | 222 | #if TARGET_OS_IPHONE || TARGET_OS_TV 223 | 224 | - (MASConstraint *)leftMargin { 225 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 226 | } 227 | 228 | - (MASConstraint *)rightMargin { 229 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 230 | } 231 | 232 | - (MASConstraint *)topMargin { 233 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 234 | } 235 | 236 | - (MASConstraint *)bottomMargin { 237 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 238 | } 239 | 240 | - (MASConstraint *)leadingMargin { 241 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 242 | } 243 | 244 | - (MASConstraint *)trailingMargin { 245 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 246 | } 247 | 248 | - (MASConstraint *)centerXWithinMargins { 249 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 250 | } 251 | 252 | - (MASConstraint *)centerYWithinMargins { 253 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 254 | } 255 | 256 | #endif 257 | 258 | #pragma mark - Abstract 259 | 260 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 261 | 262 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 263 | 264 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 265 | 266 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 267 | 268 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 269 | 270 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 271 | 272 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 273 | 274 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 275 | 276 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 277 | 278 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 279 | 280 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 281 | 282 | #endif 283 | 284 | - (void)activate { MASMethodNotImplemented(); } 285 | 286 | - (void)deactivate { MASMethodNotImplemented(); } 287 | 288 | - (void)install { MASMethodNotImplemented(); } 289 | 290 | - (void)uninstall { MASMethodNotImplemented(); } 291 | 292 | @end 293 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.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 TARGET_OS_IPHONE || TARGET_OS_TV 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 TARGET_OS_IPHONE || TARGET_OS_TV 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 MASConstrait 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 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASConstraintMaker.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraintMaker.h" 10 | #import "MASViewConstraint.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASConstraint+Private.h" 13 | #import "MASViewAttribute.h" 14 | #import "View+MASAdditions.h" 15 | 16 | @interface MASConstraintMaker () 17 | 18 | @property (nonatomic, weak) MAS_VIEW *view; 19 | @property (nonatomic, strong) NSMutableArray *constraints; 20 | 21 | @end 22 | 23 | @implementation MASConstraintMaker 24 | 25 | - (id)initWithView:(MAS_VIEW *)view { 26 | self = [super init]; 27 | if (!self) return nil; 28 | 29 | self.view = view; 30 | self.constraints = NSMutableArray.new; 31 | 32 | return self; 33 | } 34 | 35 | - (NSArray *)install { 36 | if (self.removeExisting) { 37 | NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view]; 38 | for (MASConstraint *constraint in installedConstraints) { 39 | [constraint uninstall]; 40 | } 41 | } 42 | NSArray *constraints = self.constraints.copy; 43 | for (MASConstraint *constraint in constraints) { 44 | constraint.updateExisting = self.updateExisting; 45 | [constraint install]; 46 | } 47 | [self.constraints removeAllObjects]; 48 | return constraints; 49 | } 50 | 51 | #pragma mark - MASConstraintDelegate 52 | 53 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 54 | NSUInteger index = [self.constraints indexOfObject:constraint]; 55 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 56 | [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint]; 57 | } 58 | 59 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 60 | MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute]; 61 | MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute]; 62 | if ([constraint isKindOfClass:MASViewConstraint.class]) { 63 | //replace with composite constraint 64 | NSArray *children = @[constraint, newConstraint]; 65 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 66 | compositeConstraint.delegate = self; 67 | [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint]; 68 | return compositeConstraint; 69 | } 70 | if (!constraint) { 71 | newConstraint.delegate = self; 72 | [self.constraints addObject:newConstraint]; 73 | } 74 | return newConstraint; 75 | } 76 | 77 | - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs { 78 | __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading 79 | | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX 80 | | MASAttributeCenterY | MASAttributeBaseline 81 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 82 | | MASAttributeFirstBaseline | MASAttributeLastBaseline 83 | #endif 84 | #if TARGET_OS_IPHONE || TARGET_OS_TV 85 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin 86 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins 87 | | MASAttributeCenterYWithinMargins 88 | #endif 89 | ); 90 | 91 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); 92 | 93 | NSMutableArray *attributes = [NSMutableArray array]; 94 | 95 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; 96 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; 97 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; 98 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; 99 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; 100 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; 101 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; 102 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; 103 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; 104 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; 105 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; 106 | 107 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 108 | 109 | if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline]; 110 | if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline]; 111 | 112 | #endif 113 | 114 | #if TARGET_OS_IPHONE || TARGET_OS_TV 115 | 116 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin]; 117 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin]; 118 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin]; 119 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin]; 120 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin]; 121 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin]; 122 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins]; 123 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins]; 124 | 125 | #endif 126 | 127 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; 128 | 129 | for (MASViewAttribute *a in attributes) { 130 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; 131 | } 132 | 133 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 134 | constraint.delegate = self; 135 | [self.constraints addObject:constraint]; 136 | return constraint; 137 | } 138 | 139 | #pragma mark - standard Attributes 140 | 141 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 142 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; 143 | } 144 | 145 | - (MASConstraint *)left { 146 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 147 | } 148 | 149 | - (MASConstraint *)top { 150 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 151 | } 152 | 153 | - (MASConstraint *)right { 154 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 155 | } 156 | 157 | - (MASConstraint *)bottom { 158 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 159 | } 160 | 161 | - (MASConstraint *)leading { 162 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 163 | } 164 | 165 | - (MASConstraint *)trailing { 166 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 167 | } 168 | 169 | - (MASConstraint *)width { 170 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 171 | } 172 | 173 | - (MASConstraint *)height { 174 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 175 | } 176 | 177 | - (MASConstraint *)centerX { 178 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 179 | } 180 | 181 | - (MASConstraint *)centerY { 182 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 183 | } 184 | 185 | - (MASConstraint *)baseline { 186 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 187 | } 188 | 189 | - (MASConstraint *(^)(MASAttribute))attributes { 190 | return ^(MASAttribute attrs){ 191 | return [self addConstraintWithAttributes:attrs]; 192 | }; 193 | } 194 | 195 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 196 | 197 | - (MASConstraint *)firstBaseline { 198 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 199 | } 200 | 201 | - (MASConstraint *)lastBaseline { 202 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 203 | } 204 | 205 | #endif 206 | 207 | 208 | #if TARGET_OS_IPHONE || TARGET_OS_TV 209 | 210 | - (MASConstraint *)leftMargin { 211 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 212 | } 213 | 214 | - (MASConstraint *)rightMargin { 215 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 216 | } 217 | 218 | - (MASConstraint *)topMargin { 219 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 220 | } 221 | 222 | - (MASConstraint *)bottomMargin { 223 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 224 | } 225 | 226 | - (MASConstraint *)leadingMargin { 227 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 228 | } 229 | 230 | - (MASConstraint *)trailingMargin { 231 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 232 | } 233 | 234 | - (MASConstraint *)centerXWithinMargins { 235 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 236 | } 237 | 238 | - (MASConstraint *)centerYWithinMargins { 239 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 240 | } 241 | 242 | #endif 243 | 244 | 245 | #pragma mark - composite Attributes 246 | 247 | - (MASConstraint *)edges { 248 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; 249 | } 250 | 251 | - (MASConstraint *)size { 252 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; 253 | } 254 | 255 | - (MASConstraint *)center { 256 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; 257 | } 258 | 259 | #pragma mark - grouping 260 | 261 | - (MASConstraint *(^)(dispatch_block_t group))group { 262 | return ^id(dispatch_block_t group) { 263 | NSInteger previousCount = self.constraints.count; 264 | group(); 265 | 266 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; 267 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 268 | constraint.delegate = self; 269 | return constraint; 270 | }; 271 | } 272 | 273 | @end 274 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | #if TARGET_OS_IPHONE || TARGET_OS_TV 14 | 15 | #import 16 | #define MAS_VIEW UIView 17 | #define MAS_VIEW_CONTROLLER UIViewController 18 | #define MASEdgeInsets UIEdgeInsets 19 | 20 | typedef UILayoutPriority MASLayoutPriority; 21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 26 | 27 | #elif TARGET_OS_MAC 28 | 29 | #import 30 | #define MAS_VIEW NSView 31 | #define MASEdgeInsets NSEdgeInsets 32 | 33 | typedef NSLayoutPriority MASLayoutPriority; 34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 42 | 43 | #endif 44 | 45 | /** 46 | * Allows you to attach keys to objects matching the variable names passed. 47 | * 48 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 49 | * 50 | * is equivalent to: 51 | * 52 | * MASAttachKeys(view1, view2); 53 | */ 54 | #define MASAttachKeys(...) \ 55 | { \ 56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 57 | for (id key in keyPairs.allKeys) { \ 58 | id obj = keyPairs[key]; \ 59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 60 | @"Cannot attach mas_key to %@", obj); \ 61 | [obj setMas_key:key]; \ 62 | } \ 63 | } 64 | 65 | /** 66 | * Used to create object hashes 67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 68 | */ 69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 71 | 72 | /** 73 | * Given a scalar or struct value, wraps it in NSValue 74 | * Based on EXPObjectify: https://github.com/specta/expecta 75 | */ 76 | static inline id _MASBoxValue(const char *type, ...) { 77 | va_list v; 78 | va_start(v, type); 79 | id obj = nil; 80 | if (strcmp(type, @encode(id)) == 0) { 81 | id actual = va_arg(v, id); 82 | obj = actual; 83 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 85 | obj = [NSValue value:&actual withObjCType:type]; 86 | } else if (strcmp(type, @encode(CGSize)) == 0) { 87 | CGSize actual = (CGSize)va_arg(v, CGSize); 88 | obj = [NSValue value:&actual withObjCType:type]; 89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 91 | obj = [NSValue value:&actual withObjCType:type]; 92 | } else if (strcmp(type, @encode(double)) == 0) { 93 | double actual = (double)va_arg(v, double); 94 | obj = [NSNumber numberWithDouble:actual]; 95 | } else if (strcmp(type, @encode(float)) == 0) { 96 | float actual = (float)va_arg(v, double); 97 | obj = [NSNumber numberWithFloat:actual]; 98 | } else if (strcmp(type, @encode(int)) == 0) { 99 | int actual = (int)va_arg(v, int); 100 | obj = [NSNumber numberWithInt:actual]; 101 | } else if (strcmp(type, @encode(long)) == 0) { 102 | long actual = (long)va_arg(v, long); 103 | obj = [NSNumber numberWithLong:actual]; 104 | } else if (strcmp(type, @encode(long long)) == 0) { 105 | long long actual = (long long)va_arg(v, long long); 106 | obj = [NSNumber numberWithLongLong:actual]; 107 | } else if (strcmp(type, @encode(short)) == 0) { 108 | short actual = (short)va_arg(v, int); 109 | obj = [NSNumber numberWithShort:actual]; 110 | } else if (strcmp(type, @encode(char)) == 0) { 111 | char actual = (char)va_arg(v, int); 112 | obj = [NSNumber numberWithChar:actual]; 113 | } else if (strcmp(type, @encode(bool)) == 0) { 114 | bool actual = (bool)va_arg(v, int); 115 | obj = [NSNumber numberWithBool:actual]; 116 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 118 | obj = [NSNumber numberWithUnsignedChar:actual]; 119 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 121 | obj = [NSNumber numberWithUnsignedInt:actual]; 122 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 124 | obj = [NSNumber numberWithUnsignedLong:actual]; 125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 127 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 128 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 130 | obj = [NSNumber numberWithUnsignedShort:actual]; 131 | } 132 | va_end(v); 133 | return obj; 134 | } 135 | 136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 137 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.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 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.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 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.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 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/MASViewConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASLayoutConstraint.h" 13 | #import "View+MASAdditions.h" 14 | #import 15 | 16 | @interface MAS_VIEW (MASConstraints) 17 | 18 | @property (nonatomic, readonly) NSMutableSet *mas_installedConstraints; 19 | 20 | @end 21 | 22 | @implementation MAS_VIEW (MASConstraints) 23 | 24 | static char kInstalledConstraintsKey; 25 | 26 | - (NSMutableSet *)mas_installedConstraints { 27 | NSMutableSet *constraints = objc_getAssociatedObject(self, &kInstalledConstraintsKey); 28 | if (!constraints) { 29 | constraints = [NSMutableSet set]; 30 | objc_setAssociatedObject(self, &kInstalledConstraintsKey, constraints, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 31 | } 32 | return constraints; 33 | } 34 | 35 | @end 36 | 37 | 38 | @interface MASViewConstraint () 39 | 40 | @property (nonatomic, strong, readwrite) MASViewAttribute *secondViewAttribute; 41 | @property (nonatomic, weak) MAS_VIEW *installedView; 42 | @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint; 43 | @property (nonatomic, assign) NSLayoutRelation layoutRelation; 44 | @property (nonatomic, assign) MASLayoutPriority layoutPriority; 45 | @property (nonatomic, assign) CGFloat layoutMultiplier; 46 | @property (nonatomic, assign) CGFloat layoutConstant; 47 | @property (nonatomic, assign) BOOL hasLayoutRelation; 48 | @property (nonatomic, strong) id mas_key; 49 | @property (nonatomic, assign) BOOL useAnimator; 50 | 51 | @end 52 | 53 | @implementation MASViewConstraint 54 | 55 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute { 56 | self = [super init]; 57 | if (!self) return nil; 58 | 59 | _firstViewAttribute = firstViewAttribute; 60 | self.layoutPriority = MASLayoutPriorityRequired; 61 | self.layoutMultiplier = 1; 62 | 63 | return self; 64 | } 65 | 66 | #pragma mark - NSCoping 67 | 68 | - (id)copyWithZone:(NSZone __unused *)zone { 69 | MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute]; 70 | constraint.layoutConstant = self.layoutConstant; 71 | constraint.layoutRelation = self.layoutRelation; 72 | constraint.layoutPriority = self.layoutPriority; 73 | constraint.layoutMultiplier = self.layoutMultiplier; 74 | constraint.delegate = self.delegate; 75 | return constraint; 76 | } 77 | 78 | #pragma mark - Public 79 | 80 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view { 81 | return [view.mas_installedConstraints allObjects]; 82 | } 83 | 84 | #pragma mark - Private 85 | 86 | - (void)setLayoutConstant:(CGFloat)layoutConstant { 87 | _layoutConstant = layoutConstant; 88 | 89 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 90 | if (self.useAnimator) { 91 | [self.layoutConstraint.animator setConstant:layoutConstant]; 92 | } else { 93 | self.layoutConstraint.constant = layoutConstant; 94 | } 95 | #else 96 | self.layoutConstraint.constant = layoutConstant; 97 | #endif 98 | } 99 | 100 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation { 101 | _layoutRelation = layoutRelation; 102 | self.hasLayoutRelation = YES; 103 | } 104 | 105 | - (BOOL)supportsActiveProperty { 106 | return [self.layoutConstraint respondsToSelector:@selector(isActive)]; 107 | } 108 | 109 | - (BOOL)isActive { 110 | BOOL active = YES; 111 | if ([self supportsActiveProperty]) { 112 | active = [self.layoutConstraint isActive]; 113 | } 114 | 115 | return active; 116 | } 117 | 118 | - (BOOL)hasBeenInstalled { 119 | return (self.layoutConstraint != nil) && [self isActive]; 120 | } 121 | 122 | - (void)setSecondViewAttribute:(id)secondViewAttribute { 123 | if ([secondViewAttribute isKindOfClass:NSValue.class]) { 124 | [self setLayoutConstantWithValue:secondViewAttribute]; 125 | } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) { 126 | _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute]; 127 | } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) { 128 | _secondViewAttribute = secondViewAttribute; 129 | } else { 130 | NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute); 131 | } 132 | } 133 | 134 | #pragma mark - NSLayoutConstraint multiplier proxies 135 | 136 | - (MASConstraint * (^)(CGFloat))multipliedBy { 137 | return ^id(CGFloat multiplier) { 138 | NSAssert(!self.hasBeenInstalled, 139 | @"Cannot modify constraint multiplier after it has been installed"); 140 | 141 | self.layoutMultiplier = multiplier; 142 | return self; 143 | }; 144 | } 145 | 146 | 147 | - (MASConstraint * (^)(CGFloat))dividedBy { 148 | return ^id(CGFloat divider) { 149 | NSAssert(!self.hasBeenInstalled, 150 | @"Cannot modify constraint multiplier after it has been installed"); 151 | 152 | self.layoutMultiplier = 1.0/divider; 153 | return self; 154 | }; 155 | } 156 | 157 | #pragma mark - MASLayoutPriority proxy 158 | 159 | - (MASConstraint * (^)(MASLayoutPriority))priority { 160 | return ^id(MASLayoutPriority priority) { 161 | NSAssert(!self.hasBeenInstalled, 162 | @"Cannot modify constraint priority after it has been installed"); 163 | 164 | self.layoutPriority = priority; 165 | return self; 166 | }; 167 | } 168 | 169 | #pragma mark - NSLayoutRelation proxy 170 | 171 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 172 | return ^id(id attribute, NSLayoutRelation relation) { 173 | if ([attribute isKindOfClass:NSArray.class]) { 174 | NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation"); 175 | NSMutableArray *children = NSMutableArray.new; 176 | for (id attr in attribute) { 177 | MASViewConstraint *viewConstraint = [self copy]; 178 | viewConstraint.layoutRelation = relation; 179 | viewConstraint.secondViewAttribute = attr; 180 | [children addObject:viewConstraint]; 181 | } 182 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 183 | compositeConstraint.delegate = self.delegate; 184 | [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint]; 185 | return compositeConstraint; 186 | } else { 187 | NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation"); 188 | self.layoutRelation = relation; 189 | self.secondViewAttribute = attribute; 190 | return self; 191 | } 192 | }; 193 | } 194 | 195 | #pragma mark - Semantic properties 196 | 197 | - (MASConstraint *)with { 198 | return self; 199 | } 200 | 201 | - (MASConstraint *)and { 202 | return self; 203 | } 204 | 205 | #pragma mark - attribute chaining 206 | 207 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 208 | NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation"); 209 | 210 | return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 211 | } 212 | 213 | #pragma mark - Animator proxy 214 | 215 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 216 | 217 | - (MASConstraint *)animator { 218 | self.useAnimator = YES; 219 | return self; 220 | } 221 | 222 | #endif 223 | 224 | #pragma mark - debug helpers 225 | 226 | - (MASConstraint * (^)(id))key { 227 | return ^id(id key) { 228 | self.mas_key = key; 229 | return self; 230 | }; 231 | } 232 | 233 | #pragma mark - NSLayoutConstraint constant setters 234 | 235 | - (void)setInsets:(MASEdgeInsets)insets { 236 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 237 | switch (layoutAttribute) { 238 | case NSLayoutAttributeLeft: 239 | case NSLayoutAttributeLeading: 240 | self.layoutConstant = insets.left; 241 | break; 242 | case NSLayoutAttributeTop: 243 | self.layoutConstant = insets.top; 244 | break; 245 | case NSLayoutAttributeBottom: 246 | self.layoutConstant = -insets.bottom; 247 | break; 248 | case NSLayoutAttributeRight: 249 | case NSLayoutAttributeTrailing: 250 | self.layoutConstant = -insets.right; 251 | break; 252 | default: 253 | break; 254 | } 255 | } 256 | 257 | - (void)setOffset:(CGFloat)offset { 258 | self.layoutConstant = offset; 259 | } 260 | 261 | - (void)setSizeOffset:(CGSize)sizeOffset { 262 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 263 | switch (layoutAttribute) { 264 | case NSLayoutAttributeWidth: 265 | self.layoutConstant = sizeOffset.width; 266 | break; 267 | case NSLayoutAttributeHeight: 268 | self.layoutConstant = sizeOffset.height; 269 | break; 270 | default: 271 | break; 272 | } 273 | } 274 | 275 | - (void)setCenterOffset:(CGPoint)centerOffset { 276 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 277 | switch (layoutAttribute) { 278 | case NSLayoutAttributeCenterX: 279 | self.layoutConstant = centerOffset.x; 280 | break; 281 | case NSLayoutAttributeCenterY: 282 | self.layoutConstant = centerOffset.y; 283 | break; 284 | default: 285 | break; 286 | } 287 | } 288 | 289 | #pragma mark - MASConstraint 290 | 291 | - (void)activate { 292 | [self install]; 293 | } 294 | 295 | - (void)deactivate { 296 | [self uninstall]; 297 | } 298 | 299 | - (void)install { 300 | if (self.hasBeenInstalled) { 301 | return; 302 | } 303 | 304 | if ([self supportsActiveProperty] && self.layoutConstraint) { 305 | self.layoutConstraint.active = YES; 306 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; 307 | return; 308 | } 309 | 310 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item; 311 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute; 312 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item; 313 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute; 314 | 315 | // alignment attributes must have a secondViewAttribute 316 | // therefore we assume that is refering to superview 317 | // eg make.left.equalTo(@10) 318 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) { 319 | secondLayoutItem = self.firstViewAttribute.view.superview; 320 | secondLayoutAttribute = firstLayoutAttribute; 321 | } 322 | 323 | MASLayoutConstraint *layoutConstraint 324 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem 325 | attribute:firstLayoutAttribute 326 | relatedBy:self.layoutRelation 327 | toItem:secondLayoutItem 328 | attribute:secondLayoutAttribute 329 | multiplier:self.layoutMultiplier 330 | constant:self.layoutConstant]; 331 | 332 | layoutConstraint.priority = self.layoutPriority; 333 | layoutConstraint.mas_key = self.mas_key; 334 | 335 | if (self.secondViewAttribute.view) { 336 | MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view]; 337 | NSAssert(closestCommonSuperview, 338 | @"couldn't find a common superview for %@ and %@", 339 | self.firstViewAttribute.view, self.secondViewAttribute.view); 340 | self.installedView = closestCommonSuperview; 341 | } else if (self.firstViewAttribute.isSizeAttribute) { 342 | self.installedView = self.firstViewAttribute.view; 343 | } else { 344 | self.installedView = self.firstViewAttribute.view.superview; 345 | } 346 | 347 | 348 | MASLayoutConstraint *existingConstraint = nil; 349 | if (self.updateExisting) { 350 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint]; 351 | } 352 | if (existingConstraint) { 353 | // just update the constant 354 | existingConstraint.constant = layoutConstraint.constant; 355 | self.layoutConstraint = existingConstraint; 356 | } else { 357 | [self.installedView addConstraint:layoutConstraint]; 358 | self.layoutConstraint = layoutConstraint; 359 | [firstLayoutItem.mas_installedConstraints addObject:self]; 360 | } 361 | } 362 | 363 | - (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint { 364 | // check if any constraints are the same apart from the only mutable property constant 365 | 366 | // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints 367 | // and they are likely to be added first. 368 | for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) { 369 | if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue; 370 | if (existingConstraint.firstItem != layoutConstraint.firstItem) continue; 371 | if (existingConstraint.secondItem != layoutConstraint.secondItem) continue; 372 | if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue; 373 | if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue; 374 | if (existingConstraint.relation != layoutConstraint.relation) continue; 375 | if (existingConstraint.multiplier != layoutConstraint.multiplier) continue; 376 | if (existingConstraint.priority != layoutConstraint.priority) continue; 377 | 378 | return (id)existingConstraint; 379 | } 380 | return nil; 381 | } 382 | 383 | - (void)uninstall { 384 | if ([self supportsActiveProperty]) { 385 | self.layoutConstraint.active = NO; 386 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 387 | return; 388 | } 389 | 390 | [self.installedView removeConstraint:self.layoutConstraint]; 391 | self.layoutConstraint = nil; 392 | self.installedView = nil; 393 | 394 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 395 | } 396 | 397 | @end 398 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/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 (^)(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 (^)(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 (^)(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 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 42 | if (self.count < 2) { 43 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 44 | return; 45 | } 46 | 47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 48 | if (axisType == MASAxisTypeHorizontal) { 49 | MAS_VIEW *prev; 50 | for (int i = 0; i < self.count; i++) { 51 | MAS_VIEW *v = self[i]; 52 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 53 | if (prev) { 54 | make.width.equalTo(prev); 55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing); 56 | if (i == self.count - 1) {//last one 57 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 58 | } 59 | } 60 | else {//first one 61 | make.left.equalTo(tempSuperView).offset(leadSpacing); 62 | } 63 | 64 | }]; 65 | prev = v; 66 | } 67 | } 68 | else { 69 | MAS_VIEW *prev; 70 | for (int i = 0; i < self.count; i++) { 71 | MAS_VIEW *v = self[i]; 72 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 73 | if (prev) { 74 | make.height.equalTo(prev); 75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing); 76 | if (i == self.count - 1) {//last one 77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 78 | } 79 | } 80 | else {//first one 81 | make.top.equalTo(tempSuperView).offset(leadSpacing); 82 | } 83 | 84 | }]; 85 | prev = v; 86 | } 87 | } 88 | } 89 | 90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 91 | if (self.count < 2) { 92 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 93 | return; 94 | } 95 | 96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 97 | if (axisType == MASAxisTypeHorizontal) { 98 | MAS_VIEW *prev; 99 | for (int i = 0; i < self.count; i++) { 100 | MAS_VIEW *v = self[i]; 101 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 102 | make.width.equalTo(@(fixedItemLength)); 103 | if (prev) { 104 | if (i == self.count - 1) {//last one 105 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 106 | } 107 | else { 108 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 110 | } 111 | } 112 | else {//first one 113 | make.left.equalTo(tempSuperView).offset(leadSpacing); 114 | } 115 | }]; 116 | prev = v; 117 | } 118 | } 119 | else { 120 | MAS_VIEW *prev; 121 | for (int i = 0; i < self.count; i++) { 122 | MAS_VIEW *v = self[i]; 123 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 124 | make.height.equalTo(@(fixedItemLength)); 125 | if (prev) { 126 | if (i == self.count - 1) {//last one 127 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 128 | } 129 | else { 130 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 131 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 132 | } 133 | } 134 | else {//first one 135 | make.top.equalTo(tempSuperView).offset(leadSpacing); 136 | } 137 | }]; 138 | prev = v; 139 | } 140 | } 141 | } 142 | 143 | - (MAS_VIEW *)mas_commonSuperviewOfViews 144 | { 145 | MAS_VIEW *commonSuperview = nil; 146 | MAS_VIEW *previousView = nil; 147 | for (id object in self) { 148 | if ([object isKindOfClass:[MAS_VIEW class]]) { 149 | MAS_VIEW *view = (MAS_VIEW *)object; 150 | if (previousView) { 151 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 152 | } else { 153 | commonSuperview = view; 154 | } 155 | previousView = view; 156 | } 157 | } 158 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy."); 159 | return commonSuperview; 160 | } 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/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 TARGET_OS_IPHONE || TARGET_OS_TV 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 | -------------------------------------------------------------------------------- /Example/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 TARGET_OS_IPHONE || TARGET_OS_TV 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 | /** 56 | * a key to associate with this view 57 | */ 58 | @property (nonatomic, strong) id mas_key; 59 | 60 | /** 61 | * Finds the closest common superview between this view and another view 62 | * 63 | * @param view other view 64 | * 65 | * @return returns nil if common superview could not be found 66 | */ 67 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 68 | 69 | /** 70 | * Creates a MASConstraintMaker with the callee view. 71 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 72 | * 73 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 74 | * 75 | * @return Array of created MASConstraints 76 | */ 77 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 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 | * If an existing constraint exists then it will be updated instead. 83 | * 84 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 85 | * 86 | * @return Array of created/updated MASConstraints 87 | */ 88 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 89 | 90 | /** 91 | * Creates a MASConstraintMaker with the callee view. 92 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 93 | * All constraints previously installed for the view will be removed. 94 | * 95 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 96 | * 97 | * @return Array of created/updated MASConstraints 98 | */ 99 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /Example/Pods/Masonry/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 91 | 92 | - (MASViewAttribute *)mas_firstBaseline { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline]; 94 | } 95 | - (MASViewAttribute *)mas_lastBaseline { 96 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline]; 97 | } 98 | 99 | #endif 100 | 101 | #if TARGET_OS_IPHONE || TARGET_OS_TV 102 | 103 | - (MASViewAttribute *)mas_leftMargin { 104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 105 | } 106 | 107 | - (MASViewAttribute *)mas_rightMargin { 108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 109 | } 110 | 111 | - (MASViewAttribute *)mas_topMargin { 112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 113 | } 114 | 115 | - (MASViewAttribute *)mas_bottomMargin { 116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 117 | } 118 | 119 | - (MASViewAttribute *)mas_leadingMargin { 120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 121 | } 122 | 123 | - (MASViewAttribute *)mas_trailingMargin { 124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 125 | } 126 | 127 | - (MASViewAttribute *)mas_centerXWithinMargins { 128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 129 | } 130 | 131 | - (MASViewAttribute *)mas_centerYWithinMargins { 132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 133 | } 134 | 135 | #endif 136 | 137 | #pragma mark - associated properties 138 | 139 | - (id)mas_key { 140 | return objc_getAssociatedObject(self, @selector(mas_key)); 141 | } 142 | 143 | - (void)setMas_key:(id)key { 144 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 145 | } 146 | 147 | #pragma mark - heirachy 148 | 149 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 150 | MAS_VIEW *closestCommonSuperview = nil; 151 | 152 | MAS_VIEW *secondViewSuperview = view; 153 | while (!closestCommonSuperview && secondViewSuperview) { 154 | MAS_VIEW *firstViewSuperview = self; 155 | while (!closestCommonSuperview && firstViewSuperview) { 156 | if (secondViewSuperview == firstViewSuperview) { 157 | closestCommonSuperview = secondViewSuperview; 158 | } 159 | firstViewSuperview = firstViewSuperview.superview; 160 | } 161 | secondViewSuperview = secondViewSuperview.superview; 162 | } 163 | return closestCommonSuperview; 164 | } 165 | 166 | @end 167 | -------------------------------------------------------------------------------- /Example/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 TARGET_OS_IPHONE || TARGET_OS_TV 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 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 53 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 54 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 55 | 56 | @end 57 | 58 | #define MAS_ATTR_FORWARD(attr) \ 59 | - (MASViewAttribute *)attr { \ 60 | return [self mas_##attr]; \ 61 | } 62 | 63 | @implementation MAS_VIEW (MASShorthandAdditions) 64 | 65 | MAS_ATTR_FORWARD(top); 66 | MAS_ATTR_FORWARD(left); 67 | MAS_ATTR_FORWARD(bottom); 68 | MAS_ATTR_FORWARD(right); 69 | MAS_ATTR_FORWARD(leading); 70 | MAS_ATTR_FORWARD(trailing); 71 | MAS_ATTR_FORWARD(width); 72 | MAS_ATTR_FORWARD(height); 73 | MAS_ATTR_FORWARD(centerX); 74 | MAS_ATTR_FORWARD(centerY); 75 | MAS_ATTR_FORWARD(baseline); 76 | 77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 78 | 79 | MAS_ATTR_FORWARD(firstBaseline); 80 | MAS_ATTR_FORWARD(lastBaseline); 81 | 82 | #endif 83 | 84 | #if TARGET_OS_IPHONE || TARGET_OS_TV 85 | 86 | MAS_ATTR_FORWARD(leftMargin); 87 | MAS_ATTR_FORWARD(rightMargin); 88 | MAS_ATTR_FORWARD(topMargin); 89 | MAS_ATTR_FORWARD(bottomMargin); 90 | MAS_ATTR_FORWARD(leadingMargin); 91 | MAS_ATTR_FORWARD(trailingMargin); 92 | MAS_ATTR_FORWARD(centerXWithinMargins); 93 | MAS_ATTR_FORWARD(centerYWithinMargins); 94 | 95 | #endif 96 | 97 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 98 | return [self mas_attribute]; 99 | } 100 | 101 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 102 | return [self mas_makeConstraints:block]; 103 | } 104 | 105 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 106 | return [self mas_updateConstraints:block]; 107 | } 108 | 109 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 110 | return [self mas_remakeConstraints:block]; 111 | } 112 | 113 | @end 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/shevchenko.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 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/shevchenko.xcuserdatad/xcschemes/Pods-SKCalendarView.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 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/shevchenko.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Masonry.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-SKCalendarView.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 9DC8D9E02903E93BD0B2FEC9D846EA20 21 | 22 | primary 23 | 24 | 25 | A8AB1602D26043125CA7233E64420AA1 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/xiangkuilin.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 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/xiangkuilin.xcuserdatad/xcschemes/Pods-SKCalendarView.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 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/xiangkuilin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Masonry.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-SKCalendarView.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Masonry/Masonry-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Masonry : NSObject 3 | @end 4 | @implementation PodsDummy_Masonry 5 | @end 6 | -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Masonry/Masonry.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Masonry 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Masonry" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 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 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-SKCalendarView/Pods-SKCalendarView-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 | Generated by CocoaPods - https://cocoapods.org 26 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-SKCalendarView/Pods-SKCalendarView-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-SKCalendarView/Pods-SKCalendarView-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_SKCalendarView : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_SKCalendarView 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-SKCalendarView/Pods-SKCalendarView-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 63 | 64 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 65 | code_sign_cmd="$code_sign_cmd &" 66 | fi 67 | echo "$code_sign_cmd" 68 | eval "$code_sign_cmd" 69 | fi 70 | } 71 | 72 | # Strip invalid architectures 73 | strip_invalid_archs() { 74 | binary="$1" 75 | # Get architectures for current file 76 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 77 | stripped="" 78 | for arch in $archs; do 79 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 80 | # Strip non-valid architectures in-place 81 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 82 | stripped="$stripped $arch" 83 | fi 84 | done 85 | if [[ "$stripped" ]]; then 86 | echo "Stripped $binary of architectures:$stripped" 87 | fi 88 | } 89 | 90 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 91 | wait 92 | fi 93 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-SKCalendarView/Pods-SKCalendarView-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | 3) 22 | TARGET_DEVICE_ARGS="--target-device tv" 23 | ;; 24 | *) 25 | TARGET_DEVICE_ARGS="--target-device mac" 26 | ;; 27 | esac 28 | 29 | install_resource() 30 | { 31 | if [[ "$1" = /* ]] ; then 32 | RESOURCE_PATH="$1" 33 | else 34 | RESOURCE_PATH="${PODS_ROOT}/$1" 35 | fi 36 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 37 | cat << EOM 38 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 39 | EOM 40 | exit 1 41 | fi 42 | case $RESOURCE_PATH in 43 | *.storyboard) 44 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 45 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 46 | ;; 47 | *.xib) 48 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 49 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 50 | ;; 51 | *.framework) 52 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 54 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 55 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | ;; 57 | *.xcdatamodel) 58 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 59 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 60 | ;; 61 | *.xcdatamodeld) 62 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 63 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 64 | ;; 65 | *.xcmappingmodel) 66 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 67 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 68 | ;; 69 | *.xcassets) 70 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 71 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 72 | ;; 73 | *) 74 | echo "$RESOURCE_PATH" 75 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 76 | ;; 77 | esac 78 | } 79 | 80 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 83 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | fi 86 | rm -f "$RESOURCES_TO_COPY" 87 | 88 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 89 | then 90 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 91 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 92 | while read line; do 93 | if [[ $line != "${PODS_ROOT}*" ]]; then 94 | XCASSET_FILES+=("$line") 95 | fi 96 | done <<<"$OTHER_XCASSETS" 97 | 98 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 99 | fi 100 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-SKCalendarView/Pods-SKCalendarView.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit" 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 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-SKCalendarView/Pods-SKCalendarView.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit" 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 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcodeproj/project.xcworkspace/xcuserdata/shevchenko.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shevakuilin/SKCalendarView/9800a14672fb2777cd52d14bb8c151d9502dd263/Example/SKCalendarView.xcodeproj/project.xcworkspace/xcuserdata/shevchenko.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example/SKCalendarView.xcodeproj/xcuserdata/shevchenko.xcuserdatad/xcschemes/SKCalendarView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcodeproj/xcuserdata/shevchenko.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SKCalendarView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | E46BB9141E8B678400A1E1C7 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcodeproj/xcuserdata/xiangkuilin.xcuserdatad/xcschemes/SKCalendarView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcodeproj/xcuserdata/xiangkuilin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SKCalendarView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | E46BB9141E8B678400A1E1C7 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcworkspace/xcuserdata/shevchenko.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shevakuilin/SKCalendarView/9800a14672fb2777cd52d14bb8c151d9502dd263/Example/SKCalendarView.xcworkspace/xcuserdata/shevchenko.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example/SKCalendarView.xcworkspace/xcuserdata/shevchenko.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Example/SKCalendarView.xcworkspace/xcuserdata/xiangkuilin.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shevakuilin/SKCalendarView/9800a14672fb2777cd52d14bb8c151d9502dd263/Example/SKCalendarView.xcworkspace/xcuserdata/xiangkuilin.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example/SKCalendarView.xcworkspace/xcuserdata/xiangkuilin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Example/SKCalendarView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. 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 | -------------------------------------------------------------------------------- /Example/SKCalendarView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // 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. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Example/SKCalendarView/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 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /Example/SKCalendarView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/SKCalendarView/Assets.xcassets/new_loading10_400x400_@1x.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "new_loading10_400x400_@1x.png", 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 | } -------------------------------------------------------------------------------- /Example/SKCalendarView/Assets.xcassets/new_loading10_400x400_@1x.imageset/new_loading10_400x400_@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shevakuilin/SKCalendarView/9800a14672fb2777cd52d14bb8c151d9502dd263/Example/SKCalendarView/Assets.xcassets/new_loading10_400x400_@1x.imageset/new_loading10_400x400_@1x.png -------------------------------------------------------------------------------- /Example/SKCalendarView/Assets.xcassets/new_loading25_400x400_@1x.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "new_loading25_400x400_@1x.png", 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 | } -------------------------------------------------------------------------------- /Example/SKCalendarView/Assets.xcassets/new_loading25_400x400_@1x.imageset/new_loading25_400x400_@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shevakuilin/SKCalendarView/9800a14672fb2777cd52d14bb8c151d9502dd263/Example/SKCalendarView/Assets.xcassets/new_loading25_400x400_@1x.imageset/new_loading25_400x400_@1x.png -------------------------------------------------------------------------------- /Example/SKCalendarView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/SKCalendarView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/SKCalendarView/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 | 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 | 38 | 39 | -------------------------------------------------------------------------------- /Example/SKCalendarView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Example/SKCalendarView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SKConstant.h" 11 | 12 | @interface ViewController () 13 | @property (nonatomic, strong) SKCalendarView * calendarView; 14 | @property (nonatomic, strong) UIButton * nextButton; 15 | @property (nonatomic, strong) UIButton * lastButton; 16 | @property (nonatomic, strong) UILabel * chineseYearLabel;// 农历年 17 | @property (nonatomic, strong) UILabel * chineseMonthAndDayLabel; 18 | @property (nonatomic, strong) UILabel * yearLabel;// 公历年 19 | @property (nonatomic, strong) UILabel * holidayLabel;//节日&节气 20 | @property (nonatomic, strong) UIButton * backToday;// 返回今天 21 | 22 | @property (nonatomic, assign) NSUInteger lastMonth; 23 | @property (nonatomic, assign) NSUInteger nextMonth; 24 | 25 | @end 26 | 27 | @implementation ViewController 28 | 29 | - (void)viewDidLoad { 30 | [super viewDidLoad]; 31 | [self.view addSubview:self.calendarView]; 32 | 33 | // 查看下个月 34 | self.nextButton = [UIButton new]; 35 | [self.view addSubview:self.nextButton]; 36 | [self.nextButton setTitle:[NSString stringWithFormat:@"%@月", @(self.nextMonth)] forState:UIControlStateNormal]; 37 | [self.nextButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; 38 | [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) { 39 | make.top.equalTo(self.calendarView.mas_bottom); 40 | make.right.equalTo(self.calendarView.mas_right).with.offset(-10); 41 | }]; 42 | [self.nextButton addTarget:self action:@selector(checkNextMonthCalendar) forControlEvents:UIControlEventTouchUpInside]; 43 | 44 | // 查看上个月 45 | self.lastButton = [UIButton new]; 46 | [self.view addSubview:self.lastButton]; 47 | [self.lastButton setTitle:[NSString stringWithFormat:@"%@月", @(self.lastMonth)] forState:UIControlStateNormal]; 48 | [self.lastButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; 49 | [self.lastButton mas_makeConstraints:^(MASConstraintMaker *make) { 50 | make.top.equalTo(self.calendarView.mas_bottom); 51 | make.left.equalTo(self.calendarView.mas_left).with.offset(10); 52 | }]; 53 | [self.lastButton addTarget:self action:@selector(checkLastMonthCalendar) forControlEvents:UIControlEventTouchUpInside]; 54 | 55 | // 公历年 56 | self.yearLabel = [UILabel new]; 57 | [self.view addSubview:self.yearLabel]; 58 | self.yearLabel.font = [UIFont systemFontOfSize:18]; 59 | self.yearLabel.text = [NSString stringWithFormat:@"%@年%@月", @(self.calendarView.year), @(self.calendarView.month)]; 60 | [self.yearLabel mas_makeConstraints:^(MASConstraintMaker *make) { 61 | make.top.equalTo(self.calendarView.mas_bottom).with.offset(5); 62 | make.centerX.equalTo(self.calendarView); 63 | }]; 64 | 65 | // 农历年 66 | self.chineseYearLabel = [UILabel new]; 67 | [self.view addSubview:self.chineseYearLabel]; 68 | self.chineseYearLabel.font = [UIFont systemFontOfSize:18]; 69 | self.chineseYearLabel.text = [NSString stringWithFormat:@"%@年", self.calendarView.chineseYear]; 70 | self.chineseYearLabel.textAlignment = NSTextAlignmentCenter; 71 | [self.chineseYearLabel mas_makeConstraints:^(MASConstraintMaker *make) { 72 | make.top.equalTo(self.calendarView.mas_bottom).with.offset(50); 73 | make.centerX.equalTo(self.calendarView); 74 | }]; 75 | 76 | // 农历月日 77 | self.chineseMonthAndDayLabel = [UILabel new]; 78 | [self.view addSubview:self.chineseMonthAndDayLabel]; 79 | self.chineseMonthAndDayLabel.font = [UIFont systemFontOfSize:15]; 80 | self.chineseMonthAndDayLabel.textColor = [UIColor redColor]; 81 | // 默认农历日期 今天 82 | self.chineseMonthAndDayLabel.text = [NSString stringWithFormat:@"%@%@", self.calendarView.chineseCalendarMonth[self.calendarView.todayInMonth - 1], getNoneNil(self.calendarView.chineseCalendarDay[self.calendarView.todayInMonth])]; 83 | self.chineseMonthAndDayLabel.textAlignment = NSTextAlignmentCenter; 84 | [self.chineseMonthAndDayLabel mas_makeConstraints:^(MASConstraintMaker *make) { 85 | make.top.equalTo(self.chineseYearLabel.mas_bottom).with.offset(5); 86 | make.centerX.equalTo(self.chineseYearLabel); 87 | }]; 88 | 89 | // 节日&节气 90 | self.holidayLabel = [UILabel new]; 91 | [self.view addSubview:self.holidayLabel]; 92 | self.holidayLabel.font = [UIFont systemFontOfSize:15]; 93 | self.holidayLabel.textColor = [UIColor purpleColor]; 94 | self.holidayLabel.textAlignment = NSTextAlignmentCenter; 95 | // 获取节日,注意:此处传入的参数为chineseCalendarDay(包含不节日等信息) 96 | self.holidayLabel.text = [self.calendarView getHolidayAndSolarTermsWithChineseDay:getNoneNil(self.calendarView.chineseCalendarDay[self.calendarView.todayInMonth])]; 97 | [self.holidayLabel mas_makeConstraints:^(MASConstraintMaker *make) { 98 | make.top.equalTo(self.chineseMonthAndDayLabel.mas_bottom).with.offset(5); 99 | make.centerX.equalTo(self.chineseMonthAndDayLabel); 100 | }]; 101 | 102 | // 返回今天 103 | self.backToday = [UIButton new]; 104 | [self.view addSubview:self.backToday]; 105 | [self.backToday setTitle:@"返回今天" forState:UIControlStateNormal]; 106 | [self.backToday setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal]; 107 | [self.backToday mas_makeConstraints:^(MASConstraintMaker *make) { 108 | make.bottom.equalTo(self.calendarView.mas_top).with.offset(-5); 109 | make.centerX.equalTo(self.calendarView); 110 | }]; 111 | [self.backToday addTarget:self action:@selector(clickBackToday) forControlEvents:UIControlEventTouchUpInside]; 112 | } 113 | 114 | 115 | - (void)didReceiveMemoryWarning { 116 | [super didReceiveMemoryWarning]; 117 | // Dispose of any resources that can be recreated. 118 | } 119 | 120 | #pragma mark - 日历设置 121 | - (SKCalendarView *)calendarView 122 | { 123 | if (!_calendarView) { 124 | _calendarView = [[SKCalendarView alloc] initWithFrame:CGRectMake(self.view.center.x - 150, self.view.center.y - 150, 300, 300)]; 125 | _calendarView.layer.cornerRadius = 5; 126 | _calendarView.layer.borderColor = [UIColor blackColor].CGColor; 127 | _calendarView.layer.borderWidth = 0.5; 128 | _calendarView.delegate = self;// 获取点击日期的方法,一定要遵循协议 129 | _calendarView.calendarTodayTitleColor = [UIColor redColor];// 今天标题字体颜色 130 | _calendarView.calendarTodayTitle = @"今日";// 今天下标题 131 | _calendarView.dateColor = [UIColor orangeColor];// 今天日期数字背景颜色 132 | _calendarView.calendarTodayColor = [UIColor whiteColor];// 今天日期字体颜色 133 | _calendarView.dayoffInWeekColor = [UIColor redColor]; 134 | _calendarView.springColor = [UIColor colorWithRed:48 / 255.0 green:200 / 255.0 blue:104 / 255.0 alpha:1];// 春季节气颜色 135 | _calendarView.summerColor = [UIColor colorWithRed:18 / 255.0 green:96 / 255.0 blue:0 alpha:8];// 夏季节气颜色 136 | _calendarView.autumnColor = [UIColor colorWithRed:232 / 255.0 green:195 / 255.0 blue:0 / 255.0 alpha:1];// 秋季节气颜色 137 | _calendarView.winterColor = [UIColor colorWithRed:77 / 255.0 green:161 / 255.0 blue:255 / 255.0 alpha:1];// 冬季节气颜色 138 | _calendarView.holidayColor = [UIColor redColor];//节日字体颜色 139 | self.lastMonth = _calendarView.lastMonth;// 获取上个月的月份 140 | self.nextMonth = _calendarView.nextMonth;// 获取下个月的月份 141 | } 142 | 143 | return _calendarView; 144 | } 145 | 146 | #pragma mark - 查看上/下一月份日历 147 | - (void)checkNextMonthCalendar 148 | { 149 | self.calendarView.checkNextMonth = YES;// 查看下月 150 | [self changeButton:self.nextButton isNext:YES]; 151 | [SKCalendarAnimationManage animationWithView:self.calendarView andEffect:SK_ANIMATION_REVEAL isNext:YES]; 152 | self.chineseYearLabel.text = [NSString stringWithFormat:@"%@年", self.calendarView.chineseYear];// 农历年 153 | self.yearLabel.text = [NSString stringWithFormat:@"%@年%@月", @(self.calendarView.year), @(self.calendarView.month)];// 公历年 154 | } 155 | 156 | - (void)checkLastMonthCalendar 157 | { 158 | self.calendarView.checkLastMonth = YES;// 查看上月 159 | [self changeButton:self.lastButton isNext:NO]; 160 | [SKCalendarAnimationManage animationWithView:self.calendarView andEffect:SK_ANIMATION_REVEAL isNext:NO]; 161 | self.chineseYearLabel.text = [NSString stringWithFormat:@"%@年", self.calendarView.chineseYear];// 农历年 162 | self.yearLabel.text = [NSString stringWithFormat:@"%@年%@月", @(self.calendarView.year), @(self.calendarView.month)];// 公历年 163 | } 164 | 165 | // 改变上/下月按钮的月份 166 | - (void)changeButton:(UIButton *)button isNext:(BOOL)next 167 | { 168 | if (next == YES) { 169 | self.lastMonth = self.lastMonth + 1; 170 | self.nextMonth = self.nextMonth + 1; 171 | if (self.lastMonth > 12) { 172 | self.lastMonth = 1; 173 | } 174 | if (self.nextMonth > 12) { 175 | self.nextMonth = 1; 176 | } 177 | } else { 178 | self.lastMonth = self.lastMonth - 1; 179 | self.nextMonth = self.nextMonth - 1; 180 | if (self.lastMonth < 1) { 181 | self.lastMonth = 12; 182 | } 183 | if (self.nextMonth < 1) { 184 | self.nextMonth = 12; 185 | } 186 | } 187 | [self.lastButton setTitle:[NSString stringWithFormat:@"%@月", @(self.lastMonth)] forState:UIControlStateNormal]; 188 | [self.nextButton setTitle:[NSString stringWithFormat:@"%@月", @(self.nextMonth)] forState:UIControlStateNormal]; 189 | } 190 | 191 | #pragma mark - 点击日期 192 | - (void)selectDateWithRow:(NSUInteger)row 193 | { 194 | self.chineseMonthAndDayLabel.text = [NSString stringWithFormat:@"%@%@", self.calendarView.chineseCalendarMonth[row], getNoneNil(self.calendarView.chineseCalendarDay[row])]; 195 | // 获取节日,注意:此处传入的参数为chineseCalendarDay(不包含节日等信息) 196 | self.holidayLabel.text = [self.calendarView getHolidayAndSolarTermsWithChineseDay:getNoneNil(self.calendarView.chineseCalendarDay[row])]; 197 | } 198 | 199 | #pragma mark - 返回今日 200 | - (void)clickBackToday 201 | { 202 | [self.calendarView checkCalendarWithAppointDate:[NSDate date]]; 203 | self.lastMonth = _calendarView.lastMonth;// 获取上个月的月份 204 | self.nextMonth = _calendarView.nextMonth;// 获取下个月的月份 205 | [self.lastButton setTitle:[NSString stringWithFormat:@"%@月", @(self.lastMonth)] forState:UIControlStateNormal]; 206 | [self.nextButton setTitle:[NSString stringWithFormat:@"%@月", @(self.nextMonth)] forState:UIControlStateNormal]; 207 | } 208 | 209 | @end 210 | -------------------------------------------------------------------------------- /Example/SKCalendarView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. 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 | -------------------------------------------------------------------------------- /Example/podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '8.0' 2 | target ’SKCalendarView’ do 3 | pod 'Masonry', '~> 1.0.2' 4 | end -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 ShevaKuilin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 简述 2 | 3 | 4 | SKCalendarView是一个高可控性的日历基础组件,为了提高应用的自由度,默认只提供了日历部分的视图封装,但不涵盖切换月份按钮、年月分显示等非关键性控件,但请不要担心,SKCalendarView为你提供了多样性的API,你可以很轻松的拿到这些信息去展示在你自己的自定义控件中。不仅如此,SKCalendarView还为你封装了公历、农历、节假日以及中国24节气的核心算法,即使你觉得默认的视图并不合胃口,也可以直接快速的利用这套算法创造出一个全新的日历控件。最后,SKCalendarView还提供了一些简单的切换动画,如果你不喜欢它,可以忽略掉,用自己的,这里完全不会受到任何限制。如果觉得还不错,点个star吧~ 5 | 6 | ![](https://img.shields.io/badge/platform-iOS-green.svg) 7 | ![](https://img.shields.io/badge/pod-v1.6.0.beta.1-blue.svg) 8 | ![](https://img.shields.io/badge/language-ObjectiveC-purple.svg) 9 | ![](https://img.shields.io/badge/moduleVersion-v0.0.6-red.svg) 10 | 11 | ### 效果图 12 | 13 | 14 | 15 | # 如何开始 16 | 17 | 18 | 1.从GitHub上Clone-->SKCalendarView, 然后查看Demo (由于使用cocoaPods管理,请打开xcworkspace工程进行查看) 19 | 20 | 21 | 2.在项目中使用SKCalendarView,直接将目录下的SKCalendarView文件夹拷贝到工程中,或在podfile文件中添加```pod 'SKCalendarView'``` 22 | 23 | 3.SKCalendarView的默认视图基于Masonry布局,如果需要使用, 请确保你的工程里已存在Masonry,[下载地址](https://github.com/SnapKit/Masonry) 24 | 25 | 26 | 4.如果遇到其它问题,欢迎提交issues,我会及时回复 27 | 28 | 29 | # 使用方法 30 | 31 | #### 头文件导入 32 | 33 | ```objectivec 34 | #import "SKConstant.h" 35 | ``` 36 | 37 | 38 | #### 继承SKCalendarView 39 | ```objectivec 40 | @property (nonatomic, strong) SKCalendarView * calendarView; 41 | ``` 42 | 43 | 44 | #### 日历设置 45 | ```objectivec 46 | _calendarView.calendarTodayTitleColor = [UIColor redColor];// 今天标题字体颜色 47 | _calendarView.calendarTodayTitle = @"今日";// 今天下标题 48 | _calendarView.dateColor = [UIColor orangeColor];// 今天日期数字背景颜色 49 | _calendarView.calendarTodayColor = [UIColor whiteColor];// 今天日期字体颜色 50 | _calendarView.dayoffInWeekColor = [UIColor redColor]; 51 | _calendarView.springColor = [UIColor colorWithRed:48 / 255.0 green:200 / 255.0 blue:104 / 255.0 alpha:1];// 春季节气颜色 52 | _calendarView.summerColor = [UIColor colorWithRed:18 / 255.0 green:96 / 255.0 blue:0 alpha:8];// 夏季节气颜色 53 | _calendarView.autumnColor = [UIColor colorWithRed:232 / 255.0 green:195 / 255.0 blue:0 / 255.0 alpha:1];// 秋季节气颜色 54 | _calendarView.winterColor = [UIColor colorWithRed:77 / 255.0 green:161 / 255.0 blue:255 / 255.0 alpha:1];// 冬季节气颜色 55 | _calendarView.holidayColor = [UIColor redColor];//节日字体颜色 56 | self.lastMonth = _calendarView.lastMonth;// 获取上个月的月份 57 | self.nextMonth = _calendarView.nextMonth;// 获取下个月的月份 58 | ``` 59 | 60 | 61 | #### 翻页动画 62 | ```objectivec 63 | [SKCalendarAnimationManage animationWithView:self.calendarView andEffect:SK_ANIMATION_REVEAL isNext:YES]; 64 | ``` 65 | 66 | 67 | #### 获取农历年 68 | ```objectivec 69 | self.chineseYearLabel.text = [NSString stringWithFormat:@"%@年", self.calendarView.chineseYear];// 农历年 70 | ``` 71 | 72 | 73 | #### 获取农历月日 74 | ```objectivec 75 | self.chineseMonthAndDayLabel.text = [NSString stringWithFormat:@"%@%@", self.calendarView.chineseMonth, getNoneNil(self.calendarView.chineseCalendarDay[row])]; 76 | ``` 77 | 78 | 79 | #### 获取公历年/月 80 | ```objectivec 81 | self.yearLabel.text = [NSString stringWithFormat:@"%@年%@月", @(self.calendarView.year), @(self.calendarView.month)];// 公历年 82 | ``` 83 | 84 | 85 | #### 获取节日/节气 86 | ```objectivec 87 | self.holidayLabel.text = [self.calendarView getHolidayAndSolarTermsWithChineseDay:getNoneNil(self.calendarView.chineseCalendarDay[row])]; 88 | ``` 89 | 90 | 91 | 92 | #### 查询指定日期 93 | ```objectivec 94 | [self.calendarView checkCalendarWithAppointDate:[NSDate date]]; 95 | ``` 96 | 97 | 98 | 99 | #### 日历UI配置 100 | ```objectivec 101 | @property (nonatomic, strong) UIColor * weekBackgroundColor;// 周的背景颜色 102 | @property (nonatomic, strong) UIColor * normalInWeekColor;// 周(除双休日外)字体颜色 103 | @property (nonatomic, strong) UIColor * dayoffInWeekColor;// 双休日字体颜色 104 | @property (nonatomic, strong) UIColor * calendarTodayColor;// 本日日期字体颜色 105 | @property (nonatomic, strong) UIColor * dateColor;// 日期小背景颜色 106 | @property (nonatomic, strong) UIImage * dateIcon;// 日期图片 107 | @property (nonatomic, strong) UIColor * holidayBackgroundColor;// 节日背景颜色 108 | @property (nonatomic, strong) UIColor * solarTeromBackgroundColor;// 节气背景颜色 109 | @property (nonatomic, strong) UIColor * dateBackgroundColor;// 日期背景颜色(非节日&节气) 110 | @property (nonatomic, strong) UIImage * dateBackgroundIcon;// 日期背景图片 111 | @property (nonatomic, copy) NSString * calendarTodayTitle;// 本日日期标题 112 | @property (nonatomic, strong) UIColor * calendarTodayTitleColor;// 本日日期标题字体颜色 113 | @property (nonatomic, strong) UIColor * calendarTitleColor;// 日期标题字体颜色 114 | @property (nonatomic, strong) UIColor * holidayColor;// 节日标题字体颜色 115 | @property (nonatomic, strong) UIColor * springColor;// 春季节气颜色 116 | @property (nonatomic, strong) UIColor * summerColor;// 夏季节气颜色 117 | @property (nonatomic, strong) UIColor * autumnColor;// 秋季节气颜色 118 | @property (nonatomic, strong) UIColor * winterColor;// 冬季节气颜色 119 | @property (nonatomic, assign) BOOL enableClickEffect;// 开启点击效果 120 | @property (nonatomic, assign) BOOL enableDateRoundCorner;// 开启日期圆角 121 | ``` 122 | 123 | 124 | #### 获取点击的日期 125 | ```objectivec 126 | - (void)selectDateWithRow:(NSUInteger)row 127 | ``` 128 | 129 | # Q & A 130 | Q: 怎样获取当前选择日期 131 | 132 | A: 如果是直接获取已选中的公历日期的话,可以通过将选中索引传入到SKCalendarManage类的calendarDate数组中来获取已选中的日期,年和月都是可以直接通过读取year和month来获取。 133 | 如果是想到直接获取到xxxx-xx-xx格式的日期,因为具体格式可能因需求而异,所以目前没有直接提供相应的方法。后续可以考虑添加相应支持。 134 | 135 | 136 | ## 感谢你花时间阅读以上内容, 如果这个项目能够帮助到你,记得告诉我 137 | Email: shevakuilin@gmail.com 138 | -------------------------------------------------------------------------------- /SKCalendarView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "SKCalendarView" 3 | s.version = "0.0.6" 4 | s.summary = "a custom calendarView" 5 | s.description = <<-DESC 6 | a custom calendarView on iOS 7 | DESC 8 | s.homepage = "https://github.com/shevakuilin/SKCalendarView" 9 | s.license = { :type => "MIT", :file => "LICENSE" } 10 | s.author = { "ShevaKuilin" => "shevakuilin@gmail.com" } 11 | s.platform = :ios, "8.0" 12 | s.source = { :git => "https://github.com/shevakuilin/SKCalendarView.git", :tag => "0.0.6" } 13 | s.source_files = "Source/SKCalendarView/**/*.{h,m}" 14 | s.dependency "Masonry", "~> 1.0.1" 15 | 16 | end 17 | -------------------------------------------------------------------------------- /Source/SKCalendarView/Algorithm/SKCalendarManage.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKCalendarManage.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SKCalendarManage : NSObject 12 | 13 | + (SKCalendarManage *)manage; 14 | 15 | - (void)checkThisMonthRecordFromToday:(NSDate *)today; 16 | 17 | @property (nonatomic, strong) NSMutableArray * calendarDate;// 公历 18 | @property (nonatomic, strong) NSMutableArray * chineseCalendarDate;// 农历日期&节日&节气 19 | @property (nonatomic, strong) NSMutableArray * chineseCalendarDay;// 农历纯日期(不包含节日和节气) 20 | @property (nonatomic, strong) NSMutableArray * chineseCalendarMonth;// 农历月份 21 | @property (nonatomic, copy) NSArray * weekList; 22 | @property (nonatomic, assign) BOOL isIncreaseHeight;// 是否增加日历高度 23 | @property (nonatomic, assign) NSUInteger days;// 本月天数 24 | @property (nonatomic, assign) NSInteger todayInMonth;// 今天在本月是第几天 25 | @property (nonatomic, assign) NSUInteger dayInWeek;// 本月第一天是周几, 1为周日,以此类推 26 | @property (nonatomic, assign) NSUInteger year;// 当前年 27 | @property (nonatomic, assign) NSUInteger month;// 当前月 28 | @property (nonatomic, assign) NSUInteger theMonth;// 本月 29 | @property (nonatomic, copy) NSString * chineseYear;// 农历年 30 | @property (nonatomic, assign) NSUInteger todayPosition;// 今天在所属月份中所处位置 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Source/SKCalendarView/Animation/SKCalendarAnimationManage.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKCalendarAnimationManage.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/31. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | typedef NS_ENUM(NSInteger, SK_ANIMATION) { 13 | SK_ANIMATION_REVEAL,// 翻页效果 14 | SK_ANIMATION_RIPPLE,// 波纹效果 15 | SK_ANIMATION_SUCK// 吸收效果 16 | }; 17 | 18 | @interface SKCalendarAnimationManage : NSObject 19 | 20 | /** 动画效果 21 | * @param view 执行动画的view 22 | * @param effect 动画效果 23 | * @param next 查看下个月 24 | */ 25 | + (void)animationWithView:(UIView *)view andEffect:(SK_ANIMATION)effect isNext:(BOOL)next; 26 | 27 | /** 点击效果 28 | * @param view 执行动画的view 29 | */ 30 | + (void)clickEffectAnimationForView:(UIView *)view; 31 | 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Source/SKCalendarView/Animation/SKCalendarAnimationManage.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKCalendarAnimationManage.m 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/31. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import "SKCalendarAnimationManage.h" 10 | 11 | @implementation SKCalendarAnimationManage 12 | 13 | + (void)animationWithView:(UIView *)view andEffect:(SK_ANIMATION)effect isNext:(BOOL)next 14 | { 15 | CATransition * transition = [CATransition animation]; 16 | if (next == YES) {// 向下翻页 17 | switch (effect) { 18 | case SK_ANIMATION_REVEAL: 19 | transition.type = @"pageUnCurl"; 20 | transition.subtype = kCATransitionFromLeft; 21 | break; 22 | case SK_ANIMATION_RIPPLE: 23 | transition.type = @"rippleEffect"; 24 | transition.subtype = kCATransitionFromLeft; 25 | break; 26 | case SK_ANIMATION_SUCK: 27 | transition.type = @"suckEffect"; 28 | transition.subtype = kCATransitionFromLeft; 29 | break; 30 | } 31 | } else { 32 | switch (effect) { 33 | case SK_ANIMATION_REVEAL: 34 | transition.type = @"pageCurl"; 35 | transition.subtype = kCATransitionFromLeft; 36 | 37 | break; 38 | case SK_ANIMATION_RIPPLE: 39 | transition.type = @"rippleEffect"; 40 | transition.subtype = kCATransitionFromRight; 41 | break; 42 | case SK_ANIMATION_SUCK: 43 | transition.type = @"suckEffect"; 44 | transition.subtype = kCATransitionFromRight; 45 | break; 46 | } 47 | } 48 | transition.duration = 0.5; 49 | [view.layer addAnimation:transition forKey:nil]; 50 | 51 | } 52 | 53 | + (void)clickEffectAnimationForView:(UIView *)view 54 | { 55 | CABasicAnimation * scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 56 | scaleAnimation.fromValue = [NSNumber numberWithFloat:1.3]; 57 | scaleAnimation.toValue = [NSNumber numberWithFloat:0.7]; 58 | scaleAnimation.duration = 0.1; 59 | scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 60 | [view.layer addAnimation:scaleAnimation forKey:nil]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Source/SKCalendarView/Tool/SKConstant.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKConstant.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #ifndef SKConstant_h 10 | #define SKConstant_h 11 | 12 | #import "SKDateSecurity.h" 13 | #import "SKCalendarView.h" 14 | #import "SKCalendarAnimationManage.h" 15 | #import 16 | 17 | #define isEmpty(x) [SKDateSecurity isNilOrEmpty:x] 18 | #define getNoneNil(object) [SKDateSecurity getNoneNilString:object] 19 | 20 | #endif /* SKConstant_h */ 21 | -------------------------------------------------------------------------------- /Source/SKCalendarView/Tool/SKDateSecurity.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKDateSecurity.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SKDateSecurity : NSObject 12 | 13 | /** 判断给定对象是否为空 14 | * 15 | * @param string 对象 16 | * @return 是否为空 17 | * 18 | */ 19 | + (BOOL)isNilOrEmpty:(id)string; 20 | 21 | 22 | /** 将给定对象转换为字符串 23 | * 24 | * @param obj 对象 25 | * @return 字符串 26 | * 27 | */ 28 | + (NSString *)getNoneNilString:(id)obj; 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Source/SKCalendarView/Tool/SKDateSecurity.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKDateSecurity.m 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import "SKDateSecurity.h" 10 | 11 | @implementation SKDateSecurity 12 | 13 | + (BOOL)isNilOrEmpty:(id)string 14 | { 15 | if (string == nil || string == NULL) { 16 | return YES; 17 | } 18 | if ([string isKindOfClass:[NSNull class]]) { 19 | return YES; 20 | } 21 | if ([string isKindOfClass:[NSString class]] && [[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] == 0) { 22 | return YES; 23 | } 24 | if ([string isKindOfClass:[NSString class]] && ([string isEqualToString:@""] || [string isEqualToString:@"(null)"])) { 25 | return YES; 26 | } 27 | return NO; 28 | } 29 | 30 | + (NSString *)getNoneNilString:(id)obj 31 | { 32 | NSString * string = @""; 33 | if (![obj isKindOfClass:[NSNull class]]) { 34 | string = [NSString stringWithFormat:@"%@", obj]; 35 | } 36 | if (obj == nil) { 37 | string = @""; 38 | } 39 | if ([obj isKindOfClass:[NSString class]] && [obj isEqualToString:@"null"]) { 40 | string = @""; 41 | } 42 | return string; 43 | 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Source/SKCalendarView/View/SKCalendarCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKCalendarCollectionViewCell.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SKCalendarCollectionViewCell : UICollectionViewCell 12 | @property (nonatomic, copy) NSString * calendarDate;// 日期 13 | @property (nonatomic, strong) UIColor * calendarDateColor;// 日期字体颜色 14 | @property (nonatomic, strong) UIColor * dateColor;// 日期颜色 15 | @property (nonatomic, strong) UIImage * dateIcon;// 日期图片 16 | @property (nonatomic, strong) UIColor * dateBackgroundColor;// 日期背景颜色 17 | @property (nonatomic, strong) UIImage * dateBackgroundIcon;// 日期背景图片 18 | @property (nonatomic, copy) NSString * calendarTitle;// 日期标题 19 | @property (nonatomic, strong) UIColor * calendarTitleColor;// 日期标题字体颜色 20 | @property (nonatomic, assign) BOOL enableClickEffect;// 开启点击效果 21 | @property (nonatomic, assign) BOOL enableDateRoundCorner;// 开启日期圆角, 默认YES 22 | @property (nonatomic, assign) BOOL enableLine;// 开启边线, 默认YES 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Source/SKCalendarView/View/SKCalendarCollectionViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKCalendarCollectionViewCell.m 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import "SKCalendarCollectionViewCell.h" 10 | #import "SKConstant.h" 11 | 12 | @interface SKCalendarCollectionViewCell () 13 | @property (nonatomic, strong) UIView * baseView;// 底部view 14 | @property (nonatomic, strong) UIImageView * backgroundIcon;// 背景图片 15 | @property (nonatomic, strong) UIImageView * icon;// 日期图片 16 | @property (nonatomic, strong) UILabel * dateLabel;// 日期 17 | @property (nonatomic, strong) UILabel * titleLabel;// 日期标题 18 | @property (nonatomic, strong) UIImageView * rightLine;// 右边线 19 | @property (nonatomic, strong) UIImageView * bottomLine;// 下边线 20 | 21 | @end 22 | 23 | @implementation SKCalendarCollectionViewCell 24 | 25 | - (instancetype)initWithFrame:(CGRect)frame 26 | { 27 | if ([super initWithFrame:frame]) { 28 | if (self) { 29 | [self customView]; 30 | self.enableLine = YES; 31 | self.enableDateRoundCorner = YES; 32 | } 33 | } 34 | 35 | return self; 36 | } 37 | 38 | #pragma mark - 创建界面 39 | - (void)customView 40 | { 41 | // 底部view 42 | self.baseView = [UIView new]; 43 | [self addSubview:self.baseView]; 44 | self.baseView.backgroundColor = self.backgroundColor; 45 | [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) { 46 | make.edges.equalTo(self).with.insets(UIEdgeInsetsMake(0, 0, 0, 0)); 47 | }]; 48 | 49 | // 背景图片 50 | self.backgroundIcon = [UIImageView new]; 51 | [self.baseView addSubview:self.backgroundIcon]; 52 | self.backgroundIcon.alpha = 0.5; 53 | [self.backgroundIcon mas_makeConstraints:^(MASConstraintMaker *make) { 54 | make.edges.equalTo(self.baseView).with.insets(UIEdgeInsetsMake(1, 1, 1, 1)); 55 | }]; 56 | 57 | // 日期图片 58 | self.icon = [UIImageView new]; 59 | [self.baseView addSubview:self.icon]; 60 | [self.icon mas_makeConstraints:^(MASConstraintMaker *make) { 61 | make.centerX.equalTo(self.baseView); 62 | make.top.equalTo(self.baseView).with.offset(3); 63 | 64 | make.size.mas_offset(CGSizeMake(25, 25)); 65 | }]; 66 | 67 | // 日期 68 | self.dateLabel = [UILabel new]; 69 | [self.baseView addSubview:self.dateLabel]; 70 | self.dateLabel.font = [UIFont systemFontOfSize:15]; 71 | self.dateLabel.textAlignment = NSTextAlignmentCenter; 72 | [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) { 73 | make.centerY.equalTo(self.icon); 74 | make.left.equalTo(self.icon); 75 | make.right.equalTo(self.icon); 76 | }]; 77 | 78 | // 日期标题 79 | self.titleLabel = [UILabel new]; 80 | [self.baseView addSubview:self.titleLabel]; 81 | self.titleLabel.font = [UIFont systemFontOfSize:10]; 82 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 83 | [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { 84 | // make.top.equalTo(self.icon.mas_bottom).with.offset(2); 85 | make.bottom.equalTo(self.baseView).with.offset(-2); 86 | make.left.equalTo(self.baseView); 87 | make.right.equalTo(self.baseView); 88 | }]; 89 | 90 | 91 | // 边线 92 | self.rightLine = [UIImageView new]; 93 | [self addSubview:self.rightLine]; 94 | self.rightLine.backgroundColor = [UIColor lightGrayColor]; 95 | [self.rightLine mas_makeConstraints:^(MASConstraintMaker *make) { 96 | make.top.equalTo(self); 97 | make.right.equalTo(self); 98 | make.bottom.equalTo(self); 99 | 100 | make.width.mas_offset(0.5); 101 | }]; 102 | 103 | self.bottomLine = [UIImageView new]; 104 | [self addSubview:self.bottomLine]; 105 | self.bottomLine.backgroundColor = [UIColor lightGrayColor]; 106 | [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) { 107 | make.left.equalTo(self); 108 | make.right.equalTo(self); 109 | make.bottom.equalTo(self); 110 | 111 | make.height.mas_offset(0.5); 112 | }]; 113 | } 114 | 115 | #pragma mark - 外部设置 116 | - (void)setCalendarDate:(NSString *)calendarDate 117 | { 118 | _calendarDate = calendarDate; 119 | self.dateLabel.text = getNoneNil(calendarDate); 120 | } 121 | 122 | - (void)setCalendarDateColor:(UIColor *)calendarDateColor 123 | { 124 | _calendarDateColor = calendarDateColor; 125 | self.dateLabel.textColor = calendarDateColor; 126 | } 127 | 128 | - (void)setDateColor:(UIColor *)dateColor 129 | { 130 | _dateColor = dateColor; 131 | self.icon.backgroundColor = dateColor; 132 | } 133 | 134 | - (void)setDateIcon:(UIImage *)dateIcon 135 | { 136 | _dateIcon = dateIcon; 137 | if (!isEmpty(dateIcon)) { 138 | self.icon.image = dateIcon; 139 | } 140 | } 141 | 142 | - (void)setDateBackgroundColor:(UIColor *)dateBackgroundColor 143 | { 144 | _dateBackgroundColor = dateBackgroundColor; 145 | self.backgroundColor = dateBackgroundColor; 146 | self.backgroundIcon.backgroundColor = self.backgroundColor; 147 | } 148 | 149 | -(void)setDateBackgroundIcon:(UIImage *)dateBackgroundIcon 150 | { 151 | _dateBackgroundIcon = dateBackgroundIcon; 152 | self.backgroundIcon.image = dateBackgroundIcon; 153 | } 154 | 155 | - (void)setCalendarTitle:(NSString *)calendarTitle 156 | { 157 | self.titleLabel.text = calendarTitle; 158 | _calendarTitle = calendarTitle; 159 | } 160 | 161 | - (void)setCalendarTitleColor:(UIColor *)calendarTitleColor 162 | { 163 | _calendarTitleColor = calendarTitleColor; 164 | self.titleLabel.textColor = calendarTitleColor; 165 | } 166 | 167 | - (void)setEnableClickEffect:(BOOL)enableClickEffect 168 | { 169 | _enableClickEffect = enableClickEffect; 170 | if (enableClickEffect == YES) {// 开启点击效果 171 | [SKCalendarAnimationManage clickEffectAnimationForView:self.baseView]; 172 | } 173 | } 174 | 175 | - (void)setEnableDateRoundCorner:(BOOL)enableDateRoundCorner 176 | { 177 | _enableDateRoundCorner = enableDateRoundCorner; 178 | if (enableDateRoundCorner == YES) {// 开启圆角 179 | UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 25, 25) byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(10, 10)]; 180 | CAShapeLayer * maskLayer = [[CAShapeLayer alloc] init]; 181 | maskLayer.frame = CGRectMake(0, 0, 25, 25); 182 | maskLayer.path = maskPath.CGPath; 183 | self.icon.layer.mask = maskLayer; 184 | } 185 | } 186 | 187 | - (void)setEnableLine:(BOOL)enableLine 188 | { 189 | _enableLine = enableLine; 190 | if (enableLine == YES) { 191 | self.rightLine.hidden = NO; 192 | self.bottomLine.hidden = NO; 193 | } else { 194 | self.rightLine.hidden = YES; 195 | self.bottomLine.hidden = YES; 196 | } 197 | } 198 | 199 | @end 200 | -------------------------------------------------------------------------------- /Source/SKCalendarView/View/SKCalendarView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKCalendarView.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class SKCalendarView; 12 | 13 | @protocol SKCalendarViewDelegate 14 | 15 | - (void)selectDateWithRow:(NSUInteger)row; 16 | 17 | @end 18 | 19 | @interface SKCalendarView : UIView 20 | @property (nonatomic, strong) UIColor * weekBackgroundColor;// 周的背景颜色 21 | @property (nonatomic, strong) UIColor * normalInWeekColor;// 周(除双休日外)字体颜色 22 | @property (nonatomic, strong) UIColor * dayoffInWeekColor;// 双休日字体颜色 23 | @property (nonatomic, strong) UIColor * calendarTodayColor;// 本日日期字体颜色 24 | @property (nonatomic, strong) UIColor * dateColor;// 日期小背景颜色 25 | @property (nonatomic, strong) UIImage * dateIcon;// 日期图片 26 | @property (nonatomic, strong) UIColor * holidayBackgroundColor;// 节日背景颜色 27 | @property (nonatomic, strong) UIColor * solarTeromBackgroundColor;// 节气背景颜色 28 | @property (nonatomic, strong) UIColor * dateBackgroundColor;// 日期背景颜色(非节日&节气) 29 | @property (nonatomic, strong) UIImage * dateBackgroundIcon;// 日期背景图片 30 | @property (nonatomic, copy) NSString * calendarTodayTitle;// 本日日期标题 31 | @property (nonatomic, strong) UIColor * calendarTodayTitleColor;// 本日日期标题字体颜色 32 | @property (nonatomic, strong) UIColor * calendarTitleColor;// 日期标题字体颜色 33 | @property (nonatomic, strong) UIColor * holidayColor;// 节日标题字体颜色 34 | @property (nonatomic, strong) UIColor * springColor;// 春季节气颜色 35 | @property (nonatomic, strong) UIColor * summerColor;// 夏季节气颜色 36 | @property (nonatomic, strong) UIColor * autumnColor;// 秋季节气颜色 37 | @property (nonatomic, strong) UIColor * winterColor;// 冬季节气颜色 38 | @property (nonatomic, assign) BOOL enableClickEffect;// 开启点击效果 39 | @property (nonatomic, assign) BOOL enableDateRoundCorner;// 开启日期圆角 40 | @property (nonatomic, weak) id delegate; 41 | 42 | 43 | @property (nonatomic, assign) NSUInteger lastMonth;// 上个月 44 | @property (nonatomic, assign) NSUInteger nextMonth;// 下个月 45 | @property (nonatomic, assign) BOOL checkLastMonth;// 查看上个月 46 | @property (nonatomic, assign) BOOL checkNextMonth;// 查看下个月 47 | @property (nonatomic, assign) NSUInteger year;// 当前年 48 | @property (nonatomic, assign) NSUInteger month;// 当前月 49 | @property (nonatomic, copy) NSString * chineseYear;// 农历年 50 | @property (nonatomic, strong) NSMutableArray * chineseCalendarDay;// 农历纯日期(不包含节日和节气) 51 | @property (nonatomic, strong) NSMutableArray * chineseCalendarDate;// 农历日期&节日&节气 52 | @property (nonatomic, strong) NSMutableArray * chineseCalendarMonth;// 农历月份 53 | @property (nonatomic, assign) NSInteger todayInMonth;// 今天在本月是第几天 54 | 55 | /** 根据农历日期获取节日&节气 56 | * @param chineseDay 农历纯日期(不包括节日&节气) 57 | */ 58 | - (NSString *)getHolidayAndSolarTermsWithChineseDay:(NSString *)chineseDay; 59 | 60 | /** 查看指定日期 61 | * @param date 指定查看的日期 62 | */ 63 | - (void)checkCalendarWithAppointDate:(NSDate *)date; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Source/SKCalendarView/View/SKCalendarView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKCalendarView.m 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/29. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import "SKCalendarView.h" 10 | #import "SKConstant.h" 11 | #import "SKCalendarCollectionViewCell.h" 12 | #import "SKWeekCollectionViewCell.h" 13 | #import "SKCalendarManage.h" 14 | 15 | @interface SKCalendarView () 16 | @property (nonatomic, strong) UICollectionView * weekCollectionView; 17 | @property (nonatomic, strong) UICollectionView * calendarCollectionView; 18 | @property (nonatomic, strong) SKCalendarManage * calendarManage; 19 | @property (nonatomic, strong) UILabel * monthBackgroundLabel; 20 | @property (nonatomic, strong) NSDate * theDate;// 当前日期 21 | @property (nonatomic, assign) NSUInteger theYear;// 本年 22 | @property (nonatomic, assign) NSUInteger theDayInMonth;// 今天在本月所处位置 23 | @property (nonatomic, assign) NSInteger selectedRow;// 选择的日期 24 | @property (nonatomic, strong) NSString * displayChineseDate;//已显示的农历日期&节日&节气 25 | 26 | @end 27 | 28 | @implementation SKCalendarView 29 | 30 | - (instancetype)initWithFrame:(CGRect)frame 31 | { 32 | if ([super initWithFrame:frame]) { 33 | if (self) { 34 | self.frame = frame; 35 | [self customView]; 36 | } 37 | } 38 | 39 | return self; 40 | } 41 | 42 | - (SKCalendarManage *)calendarManage 43 | { 44 | if (!_calendarManage) { 45 | _calendarManage = [SKCalendarManage manage]; 46 | // 设置初始化日期,默认查看今天所处月份日历 47 | [_calendarManage checkThisMonthRecordFromToday:[NSDate date]]; 48 | self.theDate = [NSDate date]; 49 | self.theYear = _calendarManage.year; 50 | [self reloadExternalDate]; 51 | } 52 | return _calendarManage; 53 | } 54 | 55 | - (NSUInteger)lastMonth 56 | { 57 | if (_lastMonth == 0) { 58 | _lastMonth = self.calendarManage.month - 1; 59 | } 60 | return _lastMonth; 61 | } 62 | 63 | - (NSUInteger)nextMonth 64 | { 65 | if (_nextMonth == 0) { 66 | _nextMonth = self.calendarManage.month + 1; 67 | } 68 | return _nextMonth; 69 | } 70 | 71 | - (NSInteger)selectedRow 72 | { 73 | if (_selectedRow == 0) { 74 | _selectedRow = - 1; 75 | } 76 | return _selectedRow; 77 | } 78 | 79 | - (NSInteger)todayInMonth 80 | { 81 | if (_todayInMonth == 0) { 82 | _todayInMonth = self.calendarManage.todayInMonth; 83 | } 84 | return _todayInMonth; 85 | } 86 | 87 | 88 | #pragma mark - 创建界面 89 | - (void)customView 90 | { 91 | // 周 92 | UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc] init]; 93 | layout.scrollDirection = UICollectionViewScrollDirectionVertical; 94 | self.weekCollectionView = [[UICollectionView alloc] initWithFrame:self.frame collectionViewLayout:layout]; 95 | [self addSubview:self.weekCollectionView]; 96 | self.weekCollectionView.backgroundColor = [UIColor whiteColor]; 97 | self.weekCollectionView.delegate = self; 98 | self.weekCollectionView.dataSource = self; 99 | [self.weekCollectionView registerClass:[SKWeekCollectionViewCell class] forCellWithReuseIdentifier:@"Week"]; 100 | [self.weekCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { 101 | make.top.equalTo(self); 102 | make.left.equalTo(self); 103 | make.right.equalTo(self); 104 | 105 | make.height.mas_offset(self.frame.size.height / 7.5); 106 | make.height.mas_greaterThanOrEqualTo(40).priorityHigh(); 107 | }]; 108 | 109 | // 日期 110 | UICollectionViewFlowLayout * dateLayout = [[UICollectionViewFlowLayout alloc] init]; 111 | dateLayout.scrollDirection = UICollectionViewScrollDirectionVertical; 112 | self.calendarCollectionView = [[UICollectionView alloc] initWithFrame:self.frame collectionViewLayout:dateLayout]; 113 | [self addSubview:self.calendarCollectionView]; 114 | self.calendarCollectionView.backgroundColor = [UIColor whiteColor]; 115 | self.calendarCollectionView.delegate = self; 116 | self.calendarCollectionView.dataSource = self; 117 | [self.calendarCollectionView registerClass:[SKCalendarCollectionViewCell class] forCellWithReuseIdentifier:@"Calendar"]; 118 | [self.calendarCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { 119 | make.top.equalTo(self.weekCollectionView.mas_bottom); 120 | make.left.equalTo(self); 121 | make.right.equalTo(self); 122 | make.bottom.equalTo(self); 123 | }]; 124 | 125 | // 背景月份 126 | self.monthBackgroundLabel = [UILabel new]; 127 | [self addSubview:self.monthBackgroundLabel]; 128 | self.monthBackgroundLabel.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:200 / 2550.f]; 129 | self.monthBackgroundLabel.font = [UIFont systemFontOfSize:150.0f weight:120.f]; 130 | self.monthBackgroundLabel.textAlignment = NSTextAlignmentCenter; 131 | [self.monthBackgroundLabel mas_makeConstraints:^(MASConstraintMaker *make) { 132 | make.edges.equalTo(self).with.insets(UIEdgeInsetsMake(0, 0, 0, 0)); 133 | }]; 134 | } 135 | 136 | #pragma mark - 外部配置 137 | - (void)setWeekBackgroundColor:(UIColor *)weekBackgroundColor 138 | { 139 | _weekBackgroundColor = weekBackgroundColor; 140 | self.weekCollectionView.backgroundColor = weekBackgroundColor; 141 | } 142 | 143 | - (void)setNormalInWeekColor:(UIColor *)normalInWeekColor 144 | { 145 | _normalInWeekColor = normalInWeekColor; 146 | } 147 | 148 | - (void)setDayoffInWeekColor:(UIColor *)dayoffInWeekColor 149 | { 150 | _dayoffInWeekColor = dayoffInWeekColor; 151 | } 152 | 153 | 154 | - (void)setCalendarTodayColor:(UIColor *)calendarTodayColor 155 | { 156 | _calendarTodayColor = calendarTodayColor; 157 | } 158 | 159 | - (void)setDateColor:(UIColor *)dateColor 160 | { 161 | _dateColor = dateColor; 162 | } 163 | 164 | - (void)setDateIcon:(UIImage *)dateIcon 165 | { 166 | _dateIcon = dateIcon; 167 | } 168 | 169 | - (void)setHolidayBackgroundColor:(UIColor *)holidayBackgroundColor 170 | { 171 | _holidayBackgroundColor = holidayBackgroundColor; 172 | } 173 | 174 | - (void)setSolarTeromBackgroundColor:(UIColor *)solarTeromBackgroundColor 175 | { 176 | _solarTeromBackgroundColor = solarTeromBackgroundColor; 177 | } 178 | 179 | - (void)setDateBackgroundColor:(UIColor *)dateBackgroundColor 180 | { 181 | _dateBackgroundColor = dateBackgroundColor; 182 | } 183 | 184 | - (void)setSpringColor:(UIColor *)springColor 185 | { 186 | _springColor = springColor; 187 | } 188 | 189 | - (void)setSummerColor:(UIColor *)summerColor 190 | { 191 | _summerColor = summerColor; 192 | } 193 | 194 | - (void)setAutumnColor:(UIColor *)autumnColor 195 | { 196 | _autumnColor = autumnColor; 197 | } 198 | 199 | - (void)setWinterColor:(UIColor *)winterColor 200 | { 201 | _winterColor = winterColor; 202 | } 203 | 204 | - (void)setDateBackgroundIcon:(UIImage *)dateBackgroundIcon 205 | { 206 | _dateBackgroundIcon = dateBackgroundIcon; 207 | } 208 | 209 | - (void)setCalendarTodayTitle:(NSString *)calendarTodayTitle 210 | { 211 | _calendarTodayTitle = calendarTodayTitle; 212 | } 213 | 214 | - (void)setCalendarTodayTitleColor:(UIColor *)calendarTodayTitleColor 215 | { 216 | _calendarTodayTitleColor = calendarTodayTitleColor; 217 | } 218 | 219 | - (void)setHolidayColor:(UIColor *)holidayColor 220 | { 221 | _holidayColor = holidayColor; 222 | } 223 | 224 | - (void)setCalendarTitleColor:(UIColor *)calendarTitleColor 225 | { 226 | _calendarTitleColor = calendarTitleColor; 227 | } 228 | 229 | - (void)setEnableClickEffect:(BOOL)enableClickEffect 230 | { 231 | _enableClickEffect = enableClickEffect; 232 | } 233 | 234 | - (void)setEnableDateRoundCorner:(BOOL)enableDateRoundCorner 235 | { 236 | _enableDateRoundCorner = enableDateRoundCorner; 237 | } 238 | 239 | - (void)setCheckLastMonth:(BOOL)checkLastMonth 240 | { 241 | _checkLastMonth = checkLastMonth; 242 | if (checkLastMonth == YES) { 243 | self.selectedRow = -1;// 重置已选日期 244 | NSInteger hours = (self.calendarManage.days - 1) * -24; 245 | NSDate * date = [NSDate dateWithTimeInterval:hours * 60 * 60 sinceDate:self.theDate]; 246 | [self.calendarManage checkThisMonthRecordFromToday:date]; 247 | self.theDate = date; 248 | self.monthBackgroundLabel.text = [NSString stringWithFormat:@"%@", @(self.calendarManage.month)]; 249 | [self.calendarCollectionView reloadData]; 250 | [self reloadExternalDate]; 251 | } 252 | } 253 | 254 | - (void)setCheckNextMonth:(BOOL)checkNextMonth 255 | { 256 | _checkNextMonth = checkNextMonth; 257 | if (checkNextMonth == YES) { 258 | self.selectedRow = -1;// 重置已选日期 259 | NSUInteger todayInMonth = self.calendarManage.todayInMonth; 260 | if (todayInMonth > 1) { 261 | todayInMonth = self.calendarManage.todayInMonth - self.calendarManage.dayInWeek + 2; 262 | } 263 | NSUInteger day = self.calendarManage.days - todayInMonth; 264 | NSInteger hours = (day + 1) * 24; 265 | NSDate * date = [NSDate dateWithTimeInterval:hours * 60 * 60 sinceDate:self.theDate]; 266 | [self.calendarManage checkThisMonthRecordFromToday:date]; 267 | self.theDate = date; 268 | self.monthBackgroundLabel.text = [NSString stringWithFormat:@"%@", @(self.calendarManage.month)]; 269 | [self.calendarCollectionView reloadData]; 270 | [self reloadExternalDate]; 271 | } 272 | } 273 | 274 | #pragma mark - 查看指定日期 275 | - (void)checkCalendarWithAppointDate:(NSDate *)date 276 | { 277 | [self.calendarManage checkThisMonthRecordFromToday:date]; 278 | [self.calendarCollectionView reloadData]; 279 | self.theDate = date; 280 | [self reloadExternalDate]; 281 | } 282 | 283 | #pragma mark - 更新外部数据 284 | - (void)reloadExternalDate 285 | { 286 | self.year = _calendarManage.year; 287 | self.month = _calendarManage.month; 288 | self.chineseYear = _calendarManage.chineseYear; 289 | self.theDayInMonth = _calendarManage.todayPosition; 290 | self.chineseCalendarMonth = _calendarManage.chineseCalendarMonth; 291 | self.chineseCalendarDay = _calendarManage.chineseCalendarDay; 292 | self.chineseCalendarDate = _calendarManage.chineseCalendarDate; 293 | self.monthBackgroundLabel.text = [NSString stringWithFormat:@"%@", @(_calendarManage.month)]; 294 | self.lastMonth = _calendarManage.month - 1; 295 | self.nextMonth = _calendarManage.month + 1; 296 | } 297 | 298 | #pragma mark - 获取节日&节气 299 | - (NSString *)getHolidayAndSolarTermsWithChineseDay:(NSString *)chineseDay 300 | { 301 | NSString * result = @""; 302 | NSUInteger row = 0; 303 | if (self.selectedRow < 0) { 304 | row = self.todayInMonth;// 默认今天 305 | } else { 306 | row = self.selectedRow; 307 | } 308 | NSString * date = getNoneNil(self.calendarManage.chineseCalendarDate[row]); 309 | if (![chineseDay isEqualToString:date]) { 310 | result = date; 311 | } 312 | return getNoneNil(result); 313 | } 314 | 315 | 316 | #pragma mark - collectionView 317 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView 318 | { 319 | return 1; 320 | } 321 | 322 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 323 | { 324 | if (collectionView == self.calendarCollectionView) { 325 | if (self.calendarManage.isIncreaseHeight == YES) { 326 | [self.calendarCollectionView mas_updateConstraints:^(MASConstraintMaker *make) { 327 | make.height.mas_offset(6 * (self.frame.size.height / 7.5)); 328 | }]; 329 | return 42; 330 | 331 | } else { 332 | if (self.calendarCollectionView.frame.size.height > 218) { 333 | [self.calendarCollectionView mas_updateConstraints:^(MASConstraintMaker *make) { 334 | make.height.mas_offset(5 * (self.frame.size.height / 7.5)); 335 | }]; 336 | } 337 | return 35; 338 | } 339 | } 340 | 341 | return self.calendarManage.weekList.count; 342 | } 343 | 344 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 345 | { 346 | // 日期 347 | if (collectionView == self.calendarCollectionView) { 348 | SKCalendarCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Calendar" forIndexPath:indexPath]; 349 | // 是否属于双休日 350 | if ((indexPath.row + 1) % 7 == 0 || (indexPath.row + 1) % 7 == 1) { 351 | cell.calendarDateColor = self.dayoffInWeekColor; 352 | } else { 353 | cell.calendarDateColor = self.normalInWeekColor; 354 | } 355 | // 如果是选中的日期 356 | if (self.selectedRow == indexPath.row && !isEmpty(self.calendarManage.calendarDate[indexPath.row])) { 357 | cell.enableClickEffect = YES; 358 | cell.dateColor = [UIColor colorWithRed:204 / 255.0 green:228 / 255.0 blue:236 / 255.0 alpha:1.0]; 359 | cell.calendarDateColor = [UIColor whiteColor]; 360 | } else { 361 | cell.enableClickEffect = NO; 362 | cell.dateColor = nil; 363 | } 364 | // 是否属于今天 365 | if (self.theDayInMonth == indexPath.row && self.calendarManage.month == self.calendarManage.theMonth && self.theYear == self.calendarManage.year) { 366 | cell.calendarDate = getNoneNil(self.calendarManage.calendarDate[indexPath.row]);// 公历日期 367 | cell.calendarTitle = getNoneNil(self.calendarManage.chineseCalendarDate[indexPath.row]);// 农历日期 368 | cell.calendarDateColor = self.calendarTodayColor; 369 | cell.calendarTitle = getNoneNil(self.calendarTodayTitle); 370 | cell.calendarTitleColor = self.calendarTodayTitleColor; 371 | cell.dateColor = self.dateColor; 372 | 373 | } else { 374 | cell.calendarDate = getNoneNil(self.calendarManage.calendarDate[indexPath.row]);// 公历日期 375 | cell.calendarTitle = getNoneNil(self.calendarManage.chineseCalendarDate[indexPath.row]);// 农历日期 376 | cell.calendarTitleColor = nil; 377 | } 378 | // 对节日&节气进行特殊处理 379 | if (![self.calendarManage.chineseCalendarDay[indexPath.row] isEqualToString:self.calendarManage.chineseCalendarDate[indexPath.row]]) { 380 | NSString * specialDay = self.calendarManage.chineseCalendarDate[indexPath.row]; 381 | // 节气 382 | if (specialDay.length == 2 && ![specialDay isEqualToString:@"除夕"] && ![specialDay isEqualToString:@"春节"] && ![specialDay isEqualToString:@"七夕"] && ![specialDay isEqualToString:@"元旦"] && ![specialDay isEqualToString:@"小年"]) { 383 | cell.dateBackgroundIcon = self.dateBackgroundIcon; 384 | if (self.calendarManage.month >= 2 && self.calendarManage.month <= 4) {// 春季 385 | cell.calendarTitleColor = self.springColor; 386 | 387 | } else if (self.calendarManage.month >= 5 && self.calendarManage.month <= 7) {// 夏季 388 | cell.calendarTitleColor = self.summerColor; 389 | 390 | } else if (self.calendarManage.month >= 8 && self.calendarManage.month <= 10) {// 秋季 391 | cell.calendarTitleColor = self.autumnColor; 392 | 393 | } else if (self.calendarManage.month >= 11 || self.calendarManage.month == 1){// 冬季 394 | cell.calendarTitleColor = self.winterColor; 395 | } 396 | } else {// 节日 397 | if (specialDay.length == 3 || [specialDay isEqualToString:@"除夕"] || [specialDay isEqualToString:@"春节"] || [specialDay isEqualToString:@"七夕"] || [specialDay isEqualToString:@"元旦"] || [specialDay isEqualToString:@"小年"]) { 398 | cell.calendarTitleColor = self.holidayColor; 399 | cell.dateBackgroundIcon = self.dateBackgroundIcon; 400 | } 401 | } 402 | } else { 403 | cell.calendarTitleColor = self.calendarTitleColor; 404 | cell.dateBackgroundIcon = nil; 405 | } 406 | 407 | return cell; 408 | 409 | } else {// 周 410 | SKWeekCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Week" forIndexPath:indexPath]; 411 | cell.week = getNoneNil(self.calendarManage.weekList[indexPath.row]); 412 | cell.weekBackgroundColor = self.weekCollectionView.backgroundColor; 413 | if (indexPath.row == 0 || indexPath.row == self.calendarManage.weekList.count - 1) { 414 | cell.weekColor = [UIColor redColor]; 415 | } else { 416 | cell.weekColor = [UIColor blackColor]; 417 | } 418 | 419 | return cell; 420 | } 421 | } 422 | 423 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 424 | { 425 | self.selectedRow = indexPath.row; 426 | if ([self.delegate respondsToSelector:@selector(selectDateWithRow:)]) { 427 | [self.delegate selectDateWithRow:indexPath.row]; 428 | } 429 | [self.calendarCollectionView reloadData]; 430 | } 431 | 432 | -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 433 | { 434 | return CGSizeMake(self.frame.size.width / 7, self.frame.size.height / 7); 435 | } 436 | 437 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section 438 | { 439 | return 0; 440 | } 441 | 442 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section 443 | { 444 | return 0; 445 | } 446 | 447 | 448 | @end 449 | -------------------------------------------------------------------------------- /Source/SKCalendarView/View/SKWeekCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKWeekCollectionViewCell.h 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/30. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SKWeekCollectionViewCell : UICollectionViewCell 12 | @property (nonatomic, copy) NSString * week; 13 | @property (nonatomic, strong) UIColor * weekColor; 14 | @property (nonatomic, strong) UIColor * weekBackgroundColor; 15 | @property (nonatomic, assign) BOOL enableLine;// 开启边线, 默认YES 16 | 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Source/SKCalendarView/View/SKWeekCollectionViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKWeekCollectionViewCell.m 3 | // SKCalendarView 4 | // 5 | // Created by shevchenko on 17/3/30. 6 | // Copyright © 2017年 shevchenko. All rights reserved. 7 | // 8 | 9 | #import "SKWeekCollectionViewCell.h" 10 | #import "SKConstant.h" 11 | 12 | @interface SKWeekCollectionViewCell () 13 | @property (nonatomic, strong) UILabel * weekLabel; 14 | @property (nonatomic, strong) UIImageView * bottomLine; 15 | 16 | @end; 17 | 18 | @implementation SKWeekCollectionViewCell 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame 21 | { 22 | if ([super initWithFrame:frame]) { 23 | if (self) { 24 | [self customView]; 25 | self.enableLine = YES; 26 | } 27 | } 28 | 29 | return self; 30 | } 31 | 32 | #pragma mark - 创建界面 33 | - (void)customView 34 | { 35 | self.weekLabel = [UILabel new]; 36 | [self addSubview:self.weekLabel]; 37 | self.weekLabel.font = [UIFont systemFontOfSize:17]; 38 | self.weekLabel.textAlignment = NSTextAlignmentCenter; 39 | [self.weekLabel mas_makeConstraints:^(MASConstraintMaker *make) { 40 | make.center.equalTo(self); 41 | }]; 42 | 43 | self.bottomLine = [UIImageView new]; 44 | [self addSubview:self.bottomLine]; 45 | self.bottomLine.backgroundColor = [UIColor lightGrayColor]; 46 | [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) { 47 | make.left.equalTo(self); 48 | make.right.equalTo(self); 49 | make.bottom.equalTo(self).with.offset(-3); 50 | 51 | make.height.mas_offset(0.5); 52 | }]; 53 | } 54 | 55 | #pragma mark - 外部配置 56 | - (void)setWeek:(NSString *)week 57 | { 58 | _week = week; 59 | if (!isEmpty(week)) { 60 | self.weekLabel.text = week; 61 | } 62 | } 63 | 64 | - (void)setWeekColor:(UIColor *)weekColor 65 | { 66 | _weekColor = weekColor; 67 | if (!isEmpty(weekColor)) { 68 | self.weekLabel.textColor = weekColor; 69 | } 70 | } 71 | 72 | - (void)setWeekBackgroundColor:(UIColor *)weekBackgroundColor 73 | { 74 | _weekBackgroundColor = weekBackgroundColor; 75 | if (!isEmpty(weekBackgroundColor)) { 76 | self.backgroundColor = weekBackgroundColor; 77 | } 78 | } 79 | 80 | - (void)setEnableLine:(BOOL)enableLine 81 | { 82 | _enableLine = enableLine; 83 | if (enableLine == YES) { 84 | self.bottomLine.hidden = NO; 85 | } else { 86 | self.bottomLine.hidden = YES; 87 | } 88 | } 89 | 90 | @end 91 | --------------------------------------------------------------------------------