├── .gitignore ├── Demo-complex-cell.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── Demo-complex-cell.xcworkspace └── contents.xcworkspacedata ├── Demo-complex-cell ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── ComplexCell.h ├── ComplexCell.m ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── Demo-complex-cellTests ├── Demo_complex_cellTests.m └── Info.plist ├── LICENSE ├── Podfile ├── Podfile.lock ├── Pods ├── Headers │ ├── Private │ │ ├── MMPlaceHolder │ │ │ └── MMPlaceHolder.h │ │ └── 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 │ └── Public │ │ ├── MMPlaceHolder │ │ └── MMPlaceHolder.h │ │ └── 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 ├── MMPlaceHolder │ ├── LICENSE │ ├── MMPlaceHolder │ │ ├── MMPlaceHolder.h │ │ └── MMPlaceHolder.m │ └── README.md ├── Manifest.lock ├── Masonry │ ├── LICENSE │ ├── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── MASConstraintMaker.m │ │ ├── MASLayoutConstraint.h │ │ ├── MASLayoutConstraint.m │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewConstraint.h │ │ ├── MASViewConstraint.m │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASAdditions.m │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── View+MASAdditions.h │ │ ├── View+MASAdditions.m │ │ └── View+MASShorthandAdditions.h │ └── README.md ├── Pods.xcodeproj │ └── project.pbxproj └── Target Support Files │ ├── Pods-Demo-complex-cell-MMPlaceHolder │ ├── Pods-Demo-complex-cell-MMPlaceHolder-Private.xcconfig │ ├── Pods-Demo-complex-cell-MMPlaceHolder-dummy.m │ ├── Pods-Demo-complex-cell-MMPlaceHolder-prefix.pch │ └── Pods-Demo-complex-cell-MMPlaceHolder.xcconfig │ ├── Pods-Demo-complex-cell-Masonry │ ├── Pods-Demo-complex-cell-Masonry-Private.xcconfig │ ├── Pods-Demo-complex-cell-Masonry-dummy.m │ ├── Pods-Demo-complex-cell-Masonry-prefix.pch │ └── Pods-Demo-complex-cell-Masonry.xcconfig │ └── Pods-Demo-complex-cell │ ├── Pods-Demo-complex-cell-acknowledgements.markdown │ ├── Pods-Demo-complex-cell-acknowledgements.plist │ ├── Pods-Demo-complex-cell-dummy.m │ ├── Pods-Demo-complex-cell-environment.h │ ├── Pods-Demo-complex-cell-resources.sh │ ├── Pods-Demo-complex-cell.debug.xcconfig │ └── Pods-Demo-complex-cell.release.xcconfig └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /Demo-complex-cell.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 496497867DF16C075FDBFF24 /* libPods-Demo-complex-cell.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 59B996A40A985C251CFEB28D /* libPods-Demo-complex-cell.a */; }; 11 | ED6E3BAE1B268BB2007E77A7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6E3BAD1B268BB2007E77A7 /* main.m */; }; 12 | ED6E3BB11B268BB2007E77A7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6E3BB01B268BB2007E77A7 /* AppDelegate.m */; }; 13 | ED6E3BB41B268BB2007E77A7 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6E3BB31B268BB2007E77A7 /* ViewController.m */; }; 14 | ED6E3BB71B268BB2007E77A7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED6E3BB51B268BB2007E77A7 /* Main.storyboard */; }; 15 | ED6E3BB91B268BB2007E77A7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ED6E3BB81B268BB2007E77A7 /* Images.xcassets */; }; 16 | ED6E3BBC1B268BB2007E77A7 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = ED6E3BBA1B268BB2007E77A7 /* LaunchScreen.xib */; }; 17 | ED6E3BC81B268BB2007E77A7 /* Demo_complex_cellTests.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6E3BC71B268BB2007E77A7 /* Demo_complex_cellTests.m */; }; 18 | ED6E3BD31B268D0F007E77A7 /* ComplexCell.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6E3BD21B268D0F007E77A7 /* ComplexCell.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | ED6E3BC21B268BB2007E77A7 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = ED6E3BA01B268BB2007E77A7 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = ED6E3BA71B268BB2007E77A7; 27 | remoteInfo = "Demo-complex-cell"; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 0A536EEBFA558E095BD29FCE /* Pods-Demo-complex-cell.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Demo-complex-cell.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell.debug.xcconfig"; sourceTree = ""; }; 33 | 0D71C0482745D888641E4152 /* Pods-Demo-complex-cell.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Demo-complex-cell.release.xcconfig"; path = "Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell.release.xcconfig"; sourceTree = ""; }; 34 | 59B996A40A985C251CFEB28D /* libPods-Demo-complex-cell.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Demo-complex-cell.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | ED6E3BA81B268BB2007E77A7 /* Demo-complex-cell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Demo-complex-cell.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | ED6E3BAC1B268BB2007E77A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | ED6E3BAD1B268BB2007E77A7 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 38 | ED6E3BAF1B268BB2007E77A7 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 39 | ED6E3BB01B268BB2007E77A7 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 40 | ED6E3BB21B268BB2007E77A7 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 41 | ED6E3BB31B268BB2007E77A7 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 42 | ED6E3BB61B268BB2007E77A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 43 | ED6E3BB81B268BB2007E77A7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 44 | ED6E3BBB1B268BB2007E77A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 45 | ED6E3BC11B268BB2007E77A7 /* Demo-complex-cellTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Demo-complex-cellTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | ED6E3BC61B268BB2007E77A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | ED6E3BC71B268BB2007E77A7 /* Demo_complex_cellTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Demo_complex_cellTests.m; sourceTree = ""; }; 48 | ED6E3BD11B268D0F007E77A7 /* ComplexCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplexCell.h; sourceTree = ""; }; 49 | ED6E3BD21B268D0F007E77A7 /* ComplexCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComplexCell.m; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | ED6E3BA51B268BB2007E77A7 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | 496497867DF16C075FDBFF24 /* libPods-Demo-complex-cell.a in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | ED6E3BBE1B268BB2007E77A7 /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | ); 66 | runOnlyForDeploymentPostprocessing = 0; 67 | }; 68 | /* End PBXFrameworksBuildPhase section */ 69 | 70 | /* Begin PBXGroup section */ 71 | 10AE85D8C5DF34DC9215B8FA /* Pods */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 0A536EEBFA558E095BD29FCE /* Pods-Demo-complex-cell.debug.xcconfig */, 75 | 0D71C0482745D888641E4152 /* Pods-Demo-complex-cell.release.xcconfig */, 76 | ); 77 | name = Pods; 78 | sourceTree = ""; 79 | }; 80 | A2BDCB9FF3B7632F14118476 /* Frameworks */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 59B996A40A985C251CFEB28D /* libPods-Demo-complex-cell.a */, 84 | ); 85 | name = Frameworks; 86 | sourceTree = ""; 87 | }; 88 | ED6E3B9F1B268BB2007E77A7 = { 89 | isa = PBXGroup; 90 | children = ( 91 | ED6E3BAA1B268BB2007E77A7 /* Demo-complex-cell */, 92 | ED6E3BC41B268BB2007E77A7 /* Demo-complex-cellTests */, 93 | ED6E3BA91B268BB2007E77A7 /* Products */, 94 | 10AE85D8C5DF34DC9215B8FA /* Pods */, 95 | A2BDCB9FF3B7632F14118476 /* Frameworks */, 96 | ); 97 | sourceTree = ""; 98 | }; 99 | ED6E3BA91B268BB2007E77A7 /* Products */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | ED6E3BA81B268BB2007E77A7 /* Demo-complex-cell.app */, 103 | ED6E3BC11B268BB2007E77A7 /* Demo-complex-cellTests.xctest */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | ED6E3BAA1B268BB2007E77A7 /* Demo-complex-cell */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | ED6E3BAF1B268BB2007E77A7 /* AppDelegate.h */, 112 | ED6E3BB01B268BB2007E77A7 /* AppDelegate.m */, 113 | ED6E3BB21B268BB2007E77A7 /* ViewController.h */, 114 | ED6E3BB31B268BB2007E77A7 /* ViewController.m */, 115 | ED6E3BB51B268BB2007E77A7 /* Main.storyboard */, 116 | ED6E3BB81B268BB2007E77A7 /* Images.xcassets */, 117 | ED6E3BBA1B268BB2007E77A7 /* LaunchScreen.xib */, 118 | ED6E3BAB1B268BB2007E77A7 /* Supporting Files */, 119 | ED6E3BD11B268D0F007E77A7 /* ComplexCell.h */, 120 | ED6E3BD21B268D0F007E77A7 /* ComplexCell.m */, 121 | ); 122 | path = "Demo-complex-cell"; 123 | sourceTree = ""; 124 | }; 125 | ED6E3BAB1B268BB2007E77A7 /* Supporting Files */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | ED6E3BAC1B268BB2007E77A7 /* Info.plist */, 129 | ED6E3BAD1B268BB2007E77A7 /* main.m */, 130 | ); 131 | name = "Supporting Files"; 132 | sourceTree = ""; 133 | }; 134 | ED6E3BC41B268BB2007E77A7 /* Demo-complex-cellTests */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | ED6E3BC71B268BB2007E77A7 /* Demo_complex_cellTests.m */, 138 | ED6E3BC51B268BB2007E77A7 /* Supporting Files */, 139 | ); 140 | path = "Demo-complex-cellTests"; 141 | sourceTree = ""; 142 | }; 143 | ED6E3BC51B268BB2007E77A7 /* Supporting Files */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | ED6E3BC61B268BB2007E77A7 /* Info.plist */, 147 | ); 148 | name = "Supporting Files"; 149 | sourceTree = ""; 150 | }; 151 | /* End PBXGroup section */ 152 | 153 | /* Begin PBXNativeTarget section */ 154 | ED6E3BA71B268BB2007E77A7 /* Demo-complex-cell */ = { 155 | isa = PBXNativeTarget; 156 | buildConfigurationList = ED6E3BCB1B268BB2007E77A7 /* Build configuration list for PBXNativeTarget "Demo-complex-cell" */; 157 | buildPhases = ( 158 | 5C3408D2E312B34D957FB88A /* Check Pods Manifest.lock */, 159 | ED6E3BA41B268BB2007E77A7 /* Sources */, 160 | ED6E3BA51B268BB2007E77A7 /* Frameworks */, 161 | ED6E3BA61B268BB2007E77A7 /* Resources */, 162 | 30A078899FB01DFFD0B5AC6F /* Copy Pods Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = "Demo-complex-cell"; 169 | productName = "Demo-complex-cell"; 170 | productReference = ED6E3BA81B268BB2007E77A7 /* Demo-complex-cell.app */; 171 | productType = "com.apple.product-type.application"; 172 | }; 173 | ED6E3BC01B268BB2007E77A7 /* Demo-complex-cellTests */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = ED6E3BCE1B268BB2007E77A7 /* Build configuration list for PBXNativeTarget "Demo-complex-cellTests" */; 176 | buildPhases = ( 177 | ED6E3BBD1B268BB2007E77A7 /* Sources */, 178 | ED6E3BBE1B268BB2007E77A7 /* Frameworks */, 179 | ED6E3BBF1B268BB2007E77A7 /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | ED6E3BC31B268BB2007E77A7 /* PBXTargetDependency */, 185 | ); 186 | name = "Demo-complex-cellTests"; 187 | productName = "Demo-complex-cellTests"; 188 | productReference = ED6E3BC11B268BB2007E77A7 /* Demo-complex-cellTests.xctest */; 189 | productType = "com.apple.product-type.bundle.unit-test"; 190 | }; 191 | /* End PBXNativeTarget section */ 192 | 193 | /* Begin PBXProject section */ 194 | ED6E3BA01B268BB2007E77A7 /* Project object */ = { 195 | isa = PBXProject; 196 | attributes = { 197 | LastUpgradeCheck = 0630; 198 | ORGANIZATIONNAME = LJC; 199 | TargetAttributes = { 200 | ED6E3BA71B268BB2007E77A7 = { 201 | CreatedOnToolsVersion = 6.3.2; 202 | }; 203 | ED6E3BC01B268BB2007E77A7 = { 204 | CreatedOnToolsVersion = 6.3.2; 205 | TestTargetID = ED6E3BA71B268BB2007E77A7; 206 | }; 207 | }; 208 | }; 209 | buildConfigurationList = ED6E3BA31B268BB2007E77A7 /* Build configuration list for PBXProject "Demo-complex-cell" */; 210 | compatibilityVersion = "Xcode 3.2"; 211 | developmentRegion = English; 212 | hasScannedForEncodings = 0; 213 | knownRegions = ( 214 | en, 215 | Base, 216 | ); 217 | mainGroup = ED6E3B9F1B268BB2007E77A7; 218 | productRefGroup = ED6E3BA91B268BB2007E77A7 /* Products */; 219 | projectDirPath = ""; 220 | projectRoot = ""; 221 | targets = ( 222 | ED6E3BA71B268BB2007E77A7 /* Demo-complex-cell */, 223 | ED6E3BC01B268BB2007E77A7 /* Demo-complex-cellTests */, 224 | ); 225 | }; 226 | /* End PBXProject section */ 227 | 228 | /* Begin PBXResourcesBuildPhase section */ 229 | ED6E3BA61B268BB2007E77A7 /* Resources */ = { 230 | isa = PBXResourcesBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | ED6E3BB71B268BB2007E77A7 /* Main.storyboard in Resources */, 234 | ED6E3BBC1B268BB2007E77A7 /* LaunchScreen.xib in Resources */, 235 | ED6E3BB91B268BB2007E77A7 /* Images.xcassets in Resources */, 236 | ); 237 | runOnlyForDeploymentPostprocessing = 0; 238 | }; 239 | ED6E3BBF1B268BB2007E77A7 /* Resources */ = { 240 | isa = PBXResourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | ); 244 | runOnlyForDeploymentPostprocessing = 0; 245 | }; 246 | /* End PBXResourcesBuildPhase section */ 247 | 248 | /* Begin PBXShellScriptBuildPhase section */ 249 | 30A078899FB01DFFD0B5AC6F /* Copy Pods Resources */ = { 250 | isa = PBXShellScriptBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | ); 254 | inputPaths = ( 255 | ); 256 | name = "Copy Pods Resources"; 257 | outputPaths = ( 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | shellPath = /bin/sh; 261 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell-resources.sh\"\n"; 262 | showEnvVarsInLog = 0; 263 | }; 264 | 5C3408D2E312B34D957FB88A /* Check Pods Manifest.lock */ = { 265 | isa = PBXShellScriptBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | ); 269 | inputPaths = ( 270 | ); 271 | name = "Check Pods Manifest.lock"; 272 | outputPaths = ( 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | shellPath = /bin/sh; 276 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 277 | showEnvVarsInLog = 0; 278 | }; 279 | /* End PBXShellScriptBuildPhase section */ 280 | 281 | /* Begin PBXSourcesBuildPhase section */ 282 | ED6E3BA41B268BB2007E77A7 /* Sources */ = { 283 | isa = PBXSourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | ED6E3BD31B268D0F007E77A7 /* ComplexCell.m in Sources */, 287 | ED6E3BB41B268BB2007E77A7 /* ViewController.m in Sources */, 288 | ED6E3BB11B268BB2007E77A7 /* AppDelegate.m in Sources */, 289 | ED6E3BAE1B268BB2007E77A7 /* main.m in Sources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | ED6E3BBD1B268BB2007E77A7 /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | ED6E3BC81B268BB2007E77A7 /* Demo_complex_cellTests.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXTargetDependency section */ 304 | ED6E3BC31B268BB2007E77A7 /* PBXTargetDependency */ = { 305 | isa = PBXTargetDependency; 306 | target = ED6E3BA71B268BB2007E77A7 /* Demo-complex-cell */; 307 | targetProxy = ED6E3BC21B268BB2007E77A7 /* PBXContainerItemProxy */; 308 | }; 309 | /* End PBXTargetDependency section */ 310 | 311 | /* Begin PBXVariantGroup section */ 312 | ED6E3BB51B268BB2007E77A7 /* Main.storyboard */ = { 313 | isa = PBXVariantGroup; 314 | children = ( 315 | ED6E3BB61B268BB2007E77A7 /* Base */, 316 | ); 317 | name = Main.storyboard; 318 | sourceTree = ""; 319 | }; 320 | ED6E3BBA1B268BB2007E77A7 /* LaunchScreen.xib */ = { 321 | isa = PBXVariantGroup; 322 | children = ( 323 | ED6E3BBB1B268BB2007E77A7 /* Base */, 324 | ); 325 | name = LaunchScreen.xib; 326 | sourceTree = ""; 327 | }; 328 | /* End PBXVariantGroup section */ 329 | 330 | /* Begin XCBuildConfiguration section */ 331 | ED6E3BC91B268BB2007E77A7 /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | ALWAYS_SEARCH_USER_PATHS = NO; 335 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 336 | CLANG_CXX_LIBRARY = "libc++"; 337 | CLANG_ENABLE_MODULES = YES; 338 | CLANG_ENABLE_OBJC_ARC = YES; 339 | CLANG_WARN_BOOL_CONVERSION = YES; 340 | CLANG_WARN_CONSTANT_CONVERSION = YES; 341 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 342 | CLANG_WARN_EMPTY_BODY = YES; 343 | CLANG_WARN_ENUM_CONVERSION = YES; 344 | CLANG_WARN_INT_CONVERSION = YES; 345 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 346 | CLANG_WARN_UNREACHABLE_CODE = YES; 347 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 348 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 349 | COPY_PHASE_STRIP = NO; 350 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 351 | ENABLE_STRICT_OBJC_MSGSEND = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu99; 353 | GCC_DYNAMIC_NO_PIC = NO; 354 | GCC_NO_COMMON_BLOCKS = YES; 355 | GCC_OPTIMIZATION_LEVEL = 0; 356 | GCC_PREPROCESSOR_DEFINITIONS = ( 357 | "DEBUG=1", 358 | "$(inherited)", 359 | ); 360 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 361 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 362 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 363 | GCC_WARN_UNDECLARED_SELECTOR = YES; 364 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 365 | GCC_WARN_UNUSED_FUNCTION = YES; 366 | GCC_WARN_UNUSED_VARIABLE = YES; 367 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 368 | MTL_ENABLE_DEBUG_INFO = YES; 369 | ONLY_ACTIVE_ARCH = YES; 370 | SDKROOT = iphoneos; 371 | }; 372 | name = Debug; 373 | }; 374 | ED6E3BCA1B268BB2007E77A7 /* Release */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ALWAYS_SEARCH_USER_PATHS = NO; 378 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 379 | CLANG_CXX_LIBRARY = "libc++"; 380 | CLANG_ENABLE_MODULES = YES; 381 | CLANG_ENABLE_OBJC_ARC = YES; 382 | CLANG_WARN_BOOL_CONVERSION = YES; 383 | CLANG_WARN_CONSTANT_CONVERSION = YES; 384 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 385 | CLANG_WARN_EMPTY_BODY = YES; 386 | CLANG_WARN_ENUM_CONVERSION = YES; 387 | CLANG_WARN_INT_CONVERSION = YES; 388 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 389 | CLANG_WARN_UNREACHABLE_CODE = YES; 390 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 391 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 392 | COPY_PHASE_STRIP = NO; 393 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 394 | ENABLE_NS_ASSERTIONS = NO; 395 | ENABLE_STRICT_OBJC_MSGSEND = YES; 396 | GCC_C_LANGUAGE_STANDARD = gnu99; 397 | GCC_NO_COMMON_BLOCKS = YES; 398 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 399 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 400 | GCC_WARN_UNDECLARED_SELECTOR = YES; 401 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 402 | GCC_WARN_UNUSED_FUNCTION = YES; 403 | GCC_WARN_UNUSED_VARIABLE = YES; 404 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 405 | MTL_ENABLE_DEBUG_INFO = NO; 406 | SDKROOT = iphoneos; 407 | VALIDATE_PRODUCT = YES; 408 | }; 409 | name = Release; 410 | }; 411 | ED6E3BCC1B268BB2007E77A7 /* Debug */ = { 412 | isa = XCBuildConfiguration; 413 | baseConfigurationReference = 0A536EEBFA558E095BD29FCE /* Pods-Demo-complex-cell.debug.xcconfig */; 414 | buildSettings = { 415 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 416 | INFOPLIST_FILE = "Demo-complex-cell/Info.plist"; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 418 | PRODUCT_NAME = "$(TARGET_NAME)"; 419 | }; 420 | name = Debug; 421 | }; 422 | ED6E3BCD1B268BB2007E77A7 /* Release */ = { 423 | isa = XCBuildConfiguration; 424 | baseConfigurationReference = 0D71C0482745D888641E4152 /* Pods-Demo-complex-cell.release.xcconfig */; 425 | buildSettings = { 426 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 427 | INFOPLIST_FILE = "Demo-complex-cell/Info.plist"; 428 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | }; 431 | name = Release; 432 | }; 433 | ED6E3BCF1B268BB2007E77A7 /* Debug */ = { 434 | isa = XCBuildConfiguration; 435 | buildSettings = { 436 | BUNDLE_LOADER = "$(TEST_HOST)"; 437 | FRAMEWORK_SEARCH_PATHS = ( 438 | "$(SDKROOT)/Developer/Library/Frameworks", 439 | "$(inherited)", 440 | ); 441 | GCC_PREPROCESSOR_DEFINITIONS = ( 442 | "DEBUG=1", 443 | "$(inherited)", 444 | ); 445 | INFOPLIST_FILE = "Demo-complex-cellTests/Info.plist"; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Demo-complex-cell.app/Demo-complex-cell"; 449 | }; 450 | name = Debug; 451 | }; 452 | ED6E3BD01B268BB2007E77A7 /* Release */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | BUNDLE_LOADER = "$(TEST_HOST)"; 456 | FRAMEWORK_SEARCH_PATHS = ( 457 | "$(SDKROOT)/Developer/Library/Frameworks", 458 | "$(inherited)", 459 | ); 460 | INFOPLIST_FILE = "Demo-complex-cellTests/Info.plist"; 461 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 462 | PRODUCT_NAME = "$(TARGET_NAME)"; 463 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Demo-complex-cell.app/Demo-complex-cell"; 464 | }; 465 | name = Release; 466 | }; 467 | /* End XCBuildConfiguration section */ 468 | 469 | /* Begin XCConfigurationList section */ 470 | ED6E3BA31B268BB2007E77A7 /* Build configuration list for PBXProject "Demo-complex-cell" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | ED6E3BC91B268BB2007E77A7 /* Debug */, 474 | ED6E3BCA1B268BB2007E77A7 /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | defaultConfigurationName = Release; 478 | }; 479 | ED6E3BCB1B268BB2007E77A7 /* Build configuration list for PBXNativeTarget "Demo-complex-cell" */ = { 480 | isa = XCConfigurationList; 481 | buildConfigurations = ( 482 | ED6E3BCC1B268BB2007E77A7 /* Debug */, 483 | ED6E3BCD1B268BB2007E77A7 /* Release */, 484 | ); 485 | defaultConfigurationIsVisible = 0; 486 | defaultConfigurationName = Release; 487 | }; 488 | ED6E3BCE1B268BB2007E77A7 /* Build configuration list for PBXNativeTarget "Demo-complex-cellTests" */ = { 489 | isa = XCConfigurationList; 490 | buildConfigurations = ( 491 | ED6E3BCF1B268BB2007E77A7 /* Debug */, 492 | ED6E3BD01B268BB2007E77A7 /* Release */, 493 | ); 494 | defaultConfigurationIsVisible = 0; 495 | defaultConfigurationName = Release; 496 | }; 497 | /* End XCConfigurationList section */ 498 | }; 499 | rootObject = ED6E3BA01B268BB2007E77A7 /* Project object */; 500 | } 501 | -------------------------------------------------------------------------------- /Demo-complex-cell.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo-complex-cell.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Demo-complex-cell/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Demo-complex-cell 4 | // 5 | // Created by Ralph Li on 6/9/15. 6 | // Copyright (c) 2015 LJC. 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 | -------------------------------------------------------------------------------- /Demo-complex-cell/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Demo-complex-cell 4 | // 5 | // Created by Ralph Li on 6/9/15. 6 | // Copyright (c) 2015 LJC. 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 | 21 | return YES; 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 throttle down OpenGL ES frame rates. Games should use this method to pause the game. 27 | } 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | - (void)applicationWillEnterForeground:(UIApplication *)application { 35 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 36 | } 37 | 38 | - (void)applicationDidBecomeActive:(UIApplication *)application { 39 | // 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. 40 | } 41 | 42 | - (void)applicationWillTerminate:(UIApplication *)application { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Demo-complex-cell/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Demo-complex-cell/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 | -------------------------------------------------------------------------------- /Demo-complex-cell/ComplexCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // ComplexCell.h 3 | // Demo-complex-cell 4 | // 5 | // Created by Ralph Li on 6/9/15. 6 | // Copyright (c) 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, ComplexType) { 12 | ComplexType1111, 13 | ComplexType1110, 14 | ComplexType0111, 15 | ComplexType0011, 16 | ComplexType0010, 17 | ComplexType1101 18 | }; 19 | 20 | @interface ComplexCell : UITableViewCell 21 | 22 | @property (nonatomic, assign) ComplexType type; 23 | 24 | + (CGFloat) getHeightByType:(ComplexType)type; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Demo-complex-cell/ComplexCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // ComplexCell.m 3 | // Demo-complex-cell 4 | // 5 | // Created by Ralph Li on 6/9/15. 6 | // Copyright (c) 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "ComplexCell.h" 10 | #import 11 | #import 12 | 13 | @interface ComplexCell() 14 | 15 | @property (nonatomic, strong) MASConstraint *cF; //constraint first row 16 | @property (nonatomic, strong) MASConstraint *cB; //constraint blue 17 | @property (nonatomic, strong) MASConstraint *cY; //constraint yellow 18 | @property (nonatomic, strong) MASConstraint *cR; //constraint red 19 | @property (nonatomic, strong) MASConstraint *cG; //constraint green 20 | 21 | @property (nonatomic, strong) UIView *gF; //group first row 22 | @property (nonatomic, strong) UIView *gB; //group blue 23 | @property (nonatomic, strong) UIView *gY; //group yellow 24 | @property (nonatomic, strong) UIView *gR; //group red 25 | @property (nonatomic, strong) UIView *gG; //group green 26 | 27 | @property (nonatomic, strong) UIView *vB; //view blue height:30 28 | @property (nonatomic, strong) UIView *vY; //view yellow height:30 29 | @property (nonatomic, strong) UIView *vR; //view red height:30 30 | @property (nonatomic, strong) UIView *vG; //view green height:100 31 | 32 | @end 33 | 34 | @implementation ComplexCell 35 | 36 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 37 | 38 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 39 | 40 | 41 | 42 | if ( self ) { 43 | 44 | CGFloat spacing = 20.0f; 45 | 46 | 47 | self.gF = [UIView new]; 48 | [self.contentView addSubview:self.gF]; 49 | [self.gF mas_makeConstraints:^(MASConstraintMaker *make) { 50 | make.left.top.right.equalTo(self.contentView); 51 | 52 | self.cF = make.height.equalTo(@0).priority(UILayoutPriorityRequired); 53 | [self.cF deactivate]; 54 | }]; 55 | self.gF.clipsToBounds = YES; 56 | 57 | self.gB = [UIView new]; 58 | [self.gF addSubview:self.gB]; 59 | [self.gB mas_makeConstraints:^(MASConstraintMaker *make) { 60 | make.left.top.bottom.equalTo(self.gF); 61 | 62 | self.cB = make.width.equalTo(@0).priority(UILayoutPriorityRequired); 63 | [self.cB deactivate]; 64 | }]; 65 | self.gB.clipsToBounds = YES; 66 | 67 | self.gY = [UIView new]; 68 | [self.gF addSubview:self.gY]; 69 | [self.gY mas_makeConstraints:^(MASConstraintMaker *make) { 70 | make.right.top.bottom.equalTo(self.gF); 71 | make.left.equalTo(self.gB.mas_right); 72 | 73 | self.cY = make.width.equalTo(@0).priority(UILayoutPriorityRequired); 74 | [self.cY deactivate]; 75 | }]; 76 | self.gY.clipsToBounds = YES; 77 | 78 | self.gR = [UIView new]; 79 | [self.contentView addSubview:self.gR]; 80 | [self.gR mas_makeConstraints:^(MASConstraintMaker *make) { 81 | make.left.right.equalTo(self.contentView); 82 | make.top.equalTo(self.gF.mas_bottom); 83 | 84 | self.cR = make.height.equalTo(@0).priority(UILayoutPriorityRequired); 85 | [self.cR deactivate]; 86 | }]; 87 | self.gR.clipsToBounds = YES; 88 | 89 | self.gG = [UIView new]; 90 | [self.contentView addSubview:self.gG]; 91 | [self.gG mas_makeConstraints:^(MASConstraintMaker *make) { 92 | make.left.right.equalTo(self.contentView); 93 | make.top.equalTo(self.gR.mas_bottom); 94 | 95 | self.cG = make.height.equalTo(@0).priority(UILayoutPriorityRequired); 96 | [self.cG deactivate]; 97 | }]; 98 | self.gG.clipsToBounds = YES; 99 | 100 | 101 | self.vB = [UIView new]; 102 | [self.gB addSubview:self.vB]; 103 | [self.vB mas_makeConstraints:^(MASConstraintMaker *make) { 104 | make.edges.equalTo(self.gB).insets(UIEdgeInsetsMake(spacing, spacing, 0, 0)).priorityLow(); 105 | make.height.equalTo(@30); 106 | make.width.equalTo(@60); 107 | }]; 108 | self.vB.backgroundColor = [UIColor blueColor]; 109 | 110 | 111 | self.vY = [UIView new]; 112 | [self.gY addSubview:self.vY]; 113 | [self.vY mas_makeConstraints:^(MASConstraintMaker *make) { 114 | make.edges.equalTo(self.gY).insets(UIEdgeInsetsMake(spacing, spacing, 0, spacing)).priorityLow(); 115 | make.height.equalTo(@30); 116 | }]; 117 | self.vY.backgroundColor = [UIColor yellowColor]; 118 | 119 | self.vR = [UIView new]; 120 | [self.gR addSubview:self.vR]; 121 | [self.vR mas_makeConstraints:^(MASConstraintMaker *make) { 122 | make.edges.equalTo(self.gR).insets(UIEdgeInsetsMake(spacing, spacing, 0, spacing)).priorityLow(); 123 | make.height.equalTo(@30); 124 | }]; 125 | self.vR.backgroundColor = [UIColor redColor]; 126 | 127 | self.vG = [UIView new]; 128 | [self.gG addSubview:self.vG]; 129 | [self.vG mas_makeConstraints:^(MASConstraintMaker *make) { 130 | make.edges.equalTo(self.gG).insets(UIEdgeInsetsMake(spacing, spacing, 0, spacing)).priorityLow(); 131 | make.height.equalTo(@100); 132 | }]; 133 | self.vG.backgroundColor = [UIColor greenColor]; 134 | 135 | } 136 | 137 | //show group area 138 | 139 | // [MMPlaceHolderConfig defaultConfig].lineColor = [UIColor blackColor]; 140 | // 141 | // [MMPlaceHolderConfig defaultConfig].backColor = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.3]; 142 | // [self.gB showPlaceHolder]; 143 | // 144 | // [MMPlaceHolderConfig defaultConfig].backColor = [UIColor colorWithRed:1 green:1 blue:0 alpha:0.3]; 145 | // [self.gY showPlaceHolder]; 146 | // 147 | // [MMPlaceHolderConfig defaultConfig].backColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.3]; 148 | // [self.gR showPlaceHolder]; 149 | // 150 | // [MMPlaceHolderConfig defaultConfig].backColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:0.3]; 151 | // [self.gG showPlaceHolder]; 152 | 153 | return self; 154 | } 155 | 156 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 157 | [super setSelected:selected animated:animated]; 158 | 159 | // Configure the view for the selected state 160 | } 161 | 162 | - (void)setType:(ComplexType)type { 163 | 164 | [self.cF deactivate]; 165 | [self.cB deactivate]; 166 | [self.cY deactivate]; 167 | [self.cR deactivate]; 168 | [self.cG deactivate]; 169 | 170 | switch (type) { 171 | case ComplexType1111: 172 | { 173 | break; 174 | } 175 | case ComplexType0111: 176 | { 177 | [self.cB activate]; 178 | break; 179 | } 180 | case ComplexType0011: 181 | { 182 | [self.cF activate]; 183 | break; 184 | } 185 | case ComplexType1110: 186 | { 187 | [self.cG activate]; 188 | break; 189 | } 190 | case ComplexType1101: 191 | { 192 | [self.cR activate]; 193 | break; 194 | } 195 | case ComplexType0010: 196 | { 197 | [self.cF activate]; 198 | [self.cG activate]; 199 | break; 200 | } 201 | 202 | default: 203 | break; 204 | } 205 | } 206 | 207 | + (CGFloat)getHeightByType:(ComplexType)type { 208 | 209 | switch (type) { 210 | case ComplexType1111: 211 | { 212 | } 213 | case ComplexType0111: 214 | { 215 | return 20 + 30 + 20 + 30 + 20 + 100 + 20; 216 | } 217 | case ComplexType1110: 218 | { 219 | return 20 + 30 + 20 + 30 + 20; 220 | } 221 | case ComplexType0011: 222 | { 223 | } 224 | case ComplexType1101: 225 | { 226 | return 20 + 30 + 20 + 100 + 20; 227 | } 228 | case ComplexType0010: 229 | { 230 | return 20 + 30 + 20; 231 | } 232 | 233 | default: 234 | break; 235 | } 236 | 237 | return 0; 238 | } 239 | 240 | @end 241 | -------------------------------------------------------------------------------- /Demo-complex-cell/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Demo-complex-cell/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.adad184.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarHidden 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Demo-complex-cell/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Demo-complex-cell 4 | // 5 | // Created by Ralph Li on 6/9/15. 6 | // Copyright (c) 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Demo-complex-cell/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Demo-complex-cell 4 | // 5 | // Created by Ralph Li on 6/9/15. 6 | // Copyright (c) 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "ComplexCell.h" 11 | #import 12 | 13 | @interface ViewController () 14 | < 15 | UITableViewDelegate, 16 | UITableViewDataSource 17 | > 18 | 19 | @property (nonatomic, strong) UITableView *tableView; 20 | 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | // Do any additional setup after loading the view, typically from a nib. 28 | 29 | self.tableView = [UITableView new]; 30 | [self.view addSubview:self.tableView]; 31 | [self.tableView registerClass:[ComplexCell class] forCellReuseIdentifier:@"cell"]; 32 | [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { 33 | make.edges.equalTo(self.view); 34 | }]; 35 | self.tableView.delegate = self; 36 | self.tableView.dataSource = self; 37 | 38 | } 39 | 40 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 41 | return 1; 42 | } 43 | 44 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 45 | return 6; 46 | } 47 | 48 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 49 | return [ComplexCell getHeightByType:indexPath.row%6]; 50 | } 51 | 52 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 53 | 54 | ComplexCell* cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 55 | cell.type = indexPath.row%6; 56 | 57 | return cell; 58 | } 59 | 60 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 61 | 62 | } 63 | 64 | - (void)didReceiveMemoryWarning { 65 | [super didReceiveMemoryWarning]; 66 | // Dispose of any resources that can be recreated. 67 | } 68 | 69 | - (BOOL)prefersStatusBarHidden 70 | { 71 | return YES; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /Demo-complex-cell/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Demo-complex-cell 4 | // 5 | // Created by Ralph Li on 6/9/15. 6 | // Copyright (c) 2015 LJC. 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 | -------------------------------------------------------------------------------- /Demo-complex-cellTests/Demo_complex_cellTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // Demo_complex_cellTests.m 3 | // Demo-complex-cellTests 4 | // 5 | // Created by Ralph Li on 6/9/15. 6 | // Copyright (c) 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface Demo_complex_cellTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation Demo_complex_cellTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Demo-complex-cellTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.adad184.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 ralph li 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '6.0' 3 | 4 | target 'Demo-complex-cell' do 5 | 6 | pod "Masonry" 7 | pod "MMPlaceHolder" 8 | 9 | end 10 | 11 | target 'Demo-complex-cellTests' do 12 | 13 | end 14 | 15 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (0.6.1) 3 | - MMPlaceHolder (1.8) 4 | 5 | DEPENDENCIES: 6 | - Masonry 7 | - MMPlaceHolder 8 | 9 | SPEC CHECKSUMS: 10 | Masonry: 4972309f2f134de9dd312f4dc4a21359b50e6caa 11 | MMPlaceHolder: 6dbbd7d0dbaaa556eefbc75b8039fcd9f9cd576a 12 | 13 | COCOAPODS: 0.37.2 14 | -------------------------------------------------------------------------------- /Pods/Headers/Private/MMPlaceHolder/MMPlaceHolder.h: -------------------------------------------------------------------------------- 1 | ../../../MMPlaceHolder/MMPlaceHolder/MMPlaceHolder.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MMPlaceHolder/MMPlaceHolder.h: -------------------------------------------------------------------------------- 1 | ../../../MMPlaceHolder/MMPlaceHolder/MMPlaceHolder.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/MMPlaceHolder/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 ralph li 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 | -------------------------------------------------------------------------------- /Pods/MMPlaceHolder/MMPlaceHolder/MMPlaceHolder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MMPlaceHolder.h 3 | // driving 4 | // 5 | // Created by Ralph Li on 8/11/14. 6 | // Copyright (c) 2014 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MMPlaceHolderConfig : NSObject 12 | 13 | + (MMPlaceHolderConfig*) defaultConfig; 14 | 15 | @property (nonatomic, strong) UIColor *backColor; 16 | @property (nonatomic, assign) CGFloat arrowSize; 17 | @property (nonatomic, strong) UIColor *lineColor; 18 | @property (nonatomic, assign) CGFloat lineWidth; 19 | @property (nonatomic, strong) UIColor *frameColor; 20 | @property (nonatomic, assign) CGFloat frameWidth; 21 | 22 | @property (nonatomic, assign) BOOL showArrow; 23 | @property (nonatomic, assign) BOOL showText; 24 | 25 | 26 | @property (nonatomic, assign) BOOL visible; 27 | @property (nonatomic, assign) BOOL autoDisplay; 28 | @property (nonatomic, assign) BOOL autoDisplaySystemView; 29 | @property (nonatomic, strong) NSArray *visibleMemberOfClasses; 30 | @property (nonatomic, strong) NSArray *visibleKindOfClasses; 31 | 32 | @end 33 | 34 | @interface MMPlaceHolder : UIView 35 | 36 | @property (nonatomic, strong) UIColor *lineColor; 37 | @property (nonatomic, strong) UIColor *backColor; 38 | @property (nonatomic, assign) CGFloat arrowSize; 39 | @property (nonatomic, assign) CGFloat lineWidth; 40 | @property (nonatomic, strong) UIColor *frameColor; 41 | @property (nonatomic, assign) CGFloat frameWidth; 42 | 43 | @property (nonatomic, assign) BOOL showArrow; 44 | @property (nonatomic, assign) BOOL showText; 45 | 46 | @end 47 | 48 | @interface UIView(MMPlaceHolder) 49 | 50 | - (void)showPlaceHolder; 51 | - (void)showPlaceHolderWithAllSubviews; 52 | - (void)showPlaceHolderWithAllSubviews:(NSInteger)maxDepth; 53 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor; 54 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor; 55 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor arrowSize:(CGFloat)arrowSize; 56 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor arrowSize:(CGFloat)arrowSize lineWidth:(CGFloat)lineWidth; 57 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor arrowSize:(CGFloat)arrowSize lineWidth:(CGFloat)lineWidth frameWidth:(CGFloat)frameWidth frameColor:(UIColor*)frameColor; 58 | 59 | - (void)hidePlaceHolder; 60 | - (void)hidePlaceHolderWithAllSubviews; 61 | - (void)removePlaceHolder; 62 | - (void)removePlaceHolderWithAllSubviews; 63 | - (MMPlaceHolder *)getPlaceHolder; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Pods/MMPlaceHolder/MMPlaceHolder/MMPlaceHolder.m: -------------------------------------------------------------------------------- 1 | // 2 | // MMPlaceHolder.m 3 | // driving 4 | // 5 | // Created by Ralph Li on 8/11/14. 6 | // Copyright (c) 2014 LJC. All rights reserved. 7 | // 8 | 9 | #import "MMPlaceHolder.h" 10 | #import 11 | @import QuartzCore; 12 | 13 | @interface MMPlaceHolderConfig() 14 | 15 | @property (nonatomic, strong) NSArray *defaultMemberOfClasses; 16 | 17 | @end 18 | 19 | @implementation MMPlaceHolderConfig 20 | 21 | 22 | - (id)init 23 | { 24 | self = [super init]; 25 | 26 | if (self) { 27 | 28 | self.lineColor = [UIColor whiteColor]; 29 | self.backColor = [UIColor clearColor]; 30 | self.arrowSize = 3; 31 | self.lineWidth = 1; 32 | self.frameWidth = 0; 33 | self.frameColor = [UIColor redColor]; 34 | 35 | self.showArrow = YES; 36 | self.showText = YES; 37 | 38 | self.visible = YES; 39 | self.autoDisplay = NO; 40 | self.visibleKindOfClasses = @[]; 41 | self.visibleMemberOfClasses = @[]; 42 | self.defaultMemberOfClasses = @[UIImageView.class, 43 | UIButton.class, 44 | UILabel.class, 45 | UITextField.class, 46 | UITextView.class, 47 | UISwitch.class, 48 | UISlider.class, 49 | UIPageControl.class]; 50 | } 51 | 52 | return self; 53 | } 54 | 55 | 56 | - (void)setVisible:(BOOL)visible 57 | { 58 | _visible = visible; 59 | 60 | UIResponder *delegate = [UIApplication sharedApplication].delegate; 61 | 62 | if ( !visible ) 63 | { 64 | [delegate.window hidePlaceHolderWithAllSubviews]; 65 | } 66 | else 67 | { 68 | [delegate.window showPlaceHolderWithAllSubviews]; 69 | } 70 | } 71 | 72 | + (MMPlaceHolderConfig *)defaultConfig 73 | { 74 | static dispatch_once_t onceQueue; 75 | static MMPlaceHolderConfig *appInstance; 76 | 77 | dispatch_once(&onceQueue, ^{ 78 | appInstance = [[MMPlaceHolderConfig alloc] init]; 79 | }); 80 | return appInstance; 81 | } 82 | 83 | @end 84 | 85 | @interface MMPlaceHolder() 86 | 87 | 88 | @end 89 | 90 | @implementation MMPlaceHolder 91 | 92 | - (id)initWithFrame:(CGRect)frame 93 | { 94 | self = [super initWithFrame:frame]; 95 | if (self) { 96 | // Initialization code 97 | 98 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 99 | self.backgroundColor = [UIColor clearColor]; 100 | self.contentMode = UIViewContentModeRedraw; 101 | self.userInteractionEnabled = NO; 102 | 103 | self.lineColor = [MMPlaceHolderConfig defaultConfig].lineColor; 104 | self.backColor = [MMPlaceHolderConfig defaultConfig].backColor; 105 | self.arrowSize = [MMPlaceHolderConfig defaultConfig].arrowSize; 106 | self.lineWidth = [MMPlaceHolderConfig defaultConfig].lineWidth; 107 | self.frameColor = [MMPlaceHolderConfig defaultConfig].frameColor; 108 | self.frameWidth = [MMPlaceHolderConfig defaultConfig].frameWidth; 109 | 110 | self.showArrow = [MMPlaceHolderConfig defaultConfig].showArrow; 111 | self.showText = [MMPlaceHolderConfig defaultConfig].showText; 112 | } 113 | return self; 114 | } 115 | 116 | - (void)setFrameColor:(UIColor *)frameColor 117 | { 118 | _frameColor = frameColor; 119 | self.layer.borderColor = frameColor.CGColor; 120 | } 121 | 122 | - (void)setFrameWidth:(CGFloat)frameWidth 123 | { 124 | _frameWidth = frameWidth; 125 | self.layer.borderWidth = frameWidth; 126 | } 127 | // Only override drawRect: if you perform custom drawing. 128 | // An empty implementation adversely affects performance during animation. 129 | - (void)drawRect:(CGRect)rect 130 | { 131 | // Drawing code 132 | 133 | CGFloat width = rect.size.width; 134 | CGFloat height = rect.size.height; 135 | 136 | CGFloat fontSize = 4 + (MIN(width,height))/10; 137 | CGFloat arrowSize = self.arrowSize; 138 | CGFloat lineWidth = self.lineWidth; 139 | 140 | UIFont *font = [UIFont systemFontOfSize:fontSize]; 141 | 142 | //fill the back 143 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 144 | CGContextSetFillColorWithColor(ctx, self.backColor.CGColor); 145 | CGContextFillRect(ctx, rect); 146 | 147 | if ( self.showArrow ) 148 | { 149 | //strike lines & arrows 150 | CGContextSetLineWidth(ctx, lineWidth); 151 | CGContextSetStrokeColorWithColor(ctx, self.lineColor.CGColor); 152 | 153 | CGContextMoveToPoint(ctx, width/2, 0); 154 | CGContextAddLineToPoint(ctx, width/2, height); 155 | CGContextMoveToPoint(ctx, width/2, 0); 156 | CGContextAddLineToPoint(ctx, width/2-arrowSize, arrowSize); 157 | CGContextMoveToPoint(ctx, width/2, 0); 158 | CGContextAddLineToPoint(ctx, width/2+arrowSize, arrowSize); 159 | CGContextMoveToPoint(ctx, width/2, height); 160 | CGContextAddLineToPoint(ctx, width/2-arrowSize, height-arrowSize); 161 | CGContextMoveToPoint(ctx, width/2, height); 162 | CGContextAddLineToPoint(ctx, width/2+arrowSize, height-arrowSize); 163 | 164 | CGContextMoveToPoint(ctx, 0, height/2); 165 | CGContextAddLineToPoint(ctx, width, height/2); 166 | CGContextMoveToPoint(ctx, 0, height/2); 167 | CGContextAddLineToPoint(ctx, arrowSize, height/2-arrowSize); 168 | CGContextMoveToPoint(ctx, 0, height/2); 169 | CGContextAddLineToPoint(ctx, arrowSize, height/2+arrowSize); 170 | CGContextMoveToPoint(ctx, width, height/2); 171 | CGContextAddLineToPoint(ctx, width-arrowSize, height/2-arrowSize); 172 | CGContextMoveToPoint(ctx, width, height/2); 173 | CGContextAddLineToPoint(ctx, width-arrowSize, height/2+arrowSize); 174 | 175 | CGContextStrokePath(ctx); 176 | } 177 | 178 | if ( self.showText ) 179 | { 180 | //calculate the text area 181 | NSString *strLabel = [NSString stringWithFormat:@"%.0f X %.0f",width, height]; 182 | 183 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 184 | const CGSize labelSize = [strLabel sizeWithFont:font forWidth:CGFLOAT_MAX lineBreakMode:NSLineBreakByClipping]; 185 | 186 | CGFloat rectWidth = roundf(labelSize.width)+4; 187 | CGFloat rectHeight = roundf(labelSize.height)+4; 188 | 189 | //clear the area behind the textz 190 | CGRect strRect = CGRectMake(width/2-rectWidth/2, height/2-rectHeight/2, rectWidth, rectHeight); 191 | CGContextClearRect(ctx, strRect); 192 | CGContextSetFillColorWithColor(ctx, self.backColor.CGColor); 193 | CGContextFillRect(ctx, strRect); 194 | 195 | //draw text 196 | CGContextSetFillColorWithColor(ctx, self.lineColor.CGColor); 197 | [strLabel drawInRect:CGRectInset(strRect, 0, 2) withFont:font lineBreakMode:NSLineBreakByTruncatingMiddle alignment:NSTextAlignmentCenter]; 198 | #pragma GCC diagnostic warning "-Wdeprecated-declarations" 199 | } 200 | } 201 | 202 | 203 | @end 204 | 205 | 206 | @implementation UIView(MMPlaceHolder) 207 | 208 | + (void)mm_swizzleSelector:(SEL)originalSelector withSelector:(SEL)swizzledSelector { 209 | 210 | Class class = [self class]; 211 | 212 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 213 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 214 | 215 | 216 | 217 | BOOL didAddMethodInit=class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); 218 | 219 | if (didAddMethodInit) { 220 | class_addMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); 221 | }else{ 222 | method_exchangeImplementations(originalMethod, swizzledMethod); 223 | } 224 | } 225 | 226 | 227 | +(void)load{ 228 | 229 | static dispatch_once_t onceToken; 230 | dispatch_once(&onceToken, ^{ 231 | 232 | #if RELEASE 233 | 234 | #else 235 | [self mm_swizzleSelector:@selector(init) withSelector:@selector(init_mm)]; 236 | [self mm_swizzleSelector:@selector(awakeFromNib) withSelector:@selector(awakeFromNib_mm)]; 237 | [self mm_swizzleSelector:@selector(initWithFrame:) withSelector:@selector(initWithFrame_mm:)]; 238 | 239 | #endif 240 | }); 241 | } 242 | 243 | - (id)init_mm{ 244 | 245 | self = [self init_mm]; 246 | // [self checkAutoDisplay]; 247 | return self; 248 | } 249 | 250 | - (void)awakeFromNib_mm{ 251 | // [self checkAutoDisplay]; 252 | } 253 | 254 | - (id)initWithFrame_mm:(CGRect)frame{ 255 | self = [self initWithFrame_mm:frame]; 256 | // [self checkAutoDisplay]; 257 | return self; 258 | } 259 | 260 | - (void)didMoveToSuperview 261 | { 262 | [self checkAutoDisplay]; 263 | } 264 | 265 | - (void)checkAutoDisplay 266 | { 267 | if ( self.class != [MMPlaceHolder class] ) 268 | { 269 | if ( [MMPlaceHolderConfig defaultConfig].autoDisplay ) 270 | { 271 | //means self is a system bundle view 272 | if ( [NSBundle bundleForClass:[UIView class]] == [NSBundle bundleForClass:[self class]] ) 273 | { 274 | if ( ![MMPlaceHolderConfig defaultConfig].autoDisplaySystemView ) { 275 | 276 | //skip if self is not in the white list 277 | if ( ![[MMPlaceHolderConfig defaultConfig].defaultMemberOfClasses containsObject:self.class] ) 278 | { 279 | return; 280 | } 281 | } 282 | } 283 | 284 | if ([MMPlaceHolderConfig defaultConfig].visibleMemberOfClasses.count>0) 285 | { 286 | for ( Class cls in [MMPlaceHolderConfig defaultConfig].visibleMemberOfClasses ) 287 | { 288 | if ( [self isMemberOfClass:cls] ) 289 | { 290 | [self showPlaceHolder]; 291 | 292 | return; 293 | } 294 | } 295 | } 296 | else if ([MMPlaceHolderConfig defaultConfig].visibleKindOfClasses.count>0) 297 | { 298 | for ( Class cls in [MMPlaceHolderConfig defaultConfig].visibleKindOfClasses ) 299 | { 300 | if ( [self isKindOfClass:cls] ) 301 | { 302 | [self showPlaceHolder]; 303 | 304 | return; 305 | } 306 | } 307 | } 308 | else 309 | { 310 | [self showPlaceHolder]; 311 | 312 | } 313 | } 314 | } 315 | } 316 | 317 | 318 | - (void)showPlaceHolder 319 | { 320 | [self showPlaceHolderWithLineColor:[MMPlaceHolderConfig defaultConfig].lineColor]; 321 | } 322 | 323 | - (void)showPlaceHolderWithAllSubviews 324 | { 325 | [self showPlaceHolderWithAllSubviews:NSIntegerMax]; 326 | } 327 | 328 | - (void)showPlaceHolderWithAllSubviews:(NSInteger)maxDepth 329 | { 330 | if ( maxDepth > 0 ) 331 | { 332 | for ( UIView *v in self.subviews ) 333 | { 334 | [v showPlaceHolderWithAllSubviews:maxDepth-1]; 335 | } 336 | } 337 | 338 | [self showPlaceHolder]; 339 | } 340 | 341 | - (void)showPlaceHolderWithLineColor:(UIColor *)lineColor 342 | { 343 | [self showPlaceHolderWithLineColor:lineColor backColor:[MMPlaceHolderConfig defaultConfig].backColor]; 344 | } 345 | 346 | - (void)showPlaceHolderWithLineColor:(UIColor *)lineColor backColor:(UIColor *)backColor 347 | { 348 | [self showPlaceHolderWithLineColor:lineColor backColor:backColor arrowSize:[MMPlaceHolderConfig defaultConfig].arrowSize]; 349 | } 350 | 351 | 352 | - (void)showPlaceHolderWithLineColor:(UIColor *)lineColor backColor:(UIColor *)backColor arrowSize:(CGFloat)arrowSize 353 | { 354 | [self showPlaceHolderWithLineColor:lineColor backColor:backColor arrowSize:arrowSize lineWidth:[MMPlaceHolderConfig defaultConfig].lineWidth]; 355 | } 356 | 357 | 358 | - (void)showPlaceHolderWithLineColor:(UIColor *)lineColor backColor:(UIColor *)backColor arrowSize:(CGFloat)arrowSize lineWidth:(CGFloat)lineWidth 359 | { 360 | 361 | [self showPlaceHolderWithLineColor:lineColor backColor:backColor arrowSize:arrowSize lineWidth:[MMPlaceHolderConfig defaultConfig].lineWidth frameWidth:[MMPlaceHolderConfig defaultConfig].frameWidth frameColor:[MMPlaceHolderConfig defaultConfig].frameColor]; 362 | } 363 | 364 | - (void)showPlaceHolderWithLineColor:(UIColor *)lineColor backColor:(UIColor *)backColor arrowSize:(CGFloat)arrowSize lineWidth:(CGFloat)lineWidth frameWidth:(CGFloat)frameWidth frameColor:(UIColor *)frameColor 365 | { 366 | NSLog(@"%@",NSStringFromClass(self.class)); 367 | #if RELEASE 368 | 369 | #else 370 | 371 | MMPlaceHolder *placeHolder = [self getPlaceHolder]; 372 | 373 | if ( !placeHolder ) 374 | { 375 | placeHolder = [[MMPlaceHolder alloc] initWithFrame:self.bounds]; 376 | placeHolder.lineColor = lineColor; 377 | placeHolder.backColor = backColor; 378 | placeHolder.arrowSize = arrowSize; 379 | placeHolder.lineWidth = lineWidth; 380 | placeHolder.frameColor = frameColor; 381 | placeHolder.frameWidth = frameWidth; 382 | 383 | placeHolder.tag = [NSStringFromClass([MMPlaceHolder class]) hash]+(NSInteger)self; 384 | 385 | [self addSubview:placeHolder]; 386 | } 387 | 388 | placeHolder.hidden = ![MMPlaceHolderConfig defaultConfig].visible; 389 | 390 | 391 | #endif 392 | } 393 | 394 | - (void)hidePlaceHolder 395 | { 396 | MMPlaceHolder *placeHolder = [self getPlaceHolder]; 397 | 398 | if ( placeHolder ) 399 | { 400 | placeHolder.hidden = YES; 401 | } 402 | } 403 | 404 | - (void)hidePlaceHolderWithAllSubviews 405 | { 406 | for ( UIView *v in self.subviews ) 407 | { 408 | [v hidePlaceHolderWithAllSubviews]; 409 | } 410 | 411 | [self hidePlaceHolder]; 412 | } 413 | 414 | - (void)removePlaceHolder 415 | { 416 | MMPlaceHolder *placeHolder = [self getPlaceHolder]; 417 | 418 | if ( placeHolder ) 419 | { 420 | [placeHolder removeFromSuperview]; 421 | } 422 | } 423 | 424 | - (void)removePlaceHolderWithAllSubviews 425 | { 426 | for ( UIView *v in self.subviews ) 427 | { 428 | [v removePlaceHolderWithAllSubviews]; 429 | } 430 | 431 | [self removePlaceHolder]; 432 | } 433 | 434 | 435 | - (MMPlaceHolder *)getPlaceHolder 436 | { 437 | return (MMPlaceHolder*)[self viewWithTag:[NSStringFromClass([MMPlaceHolder class]) hash]+(NSInteger)self]; 438 | } 439 | 440 | @end 441 | -------------------------------------------------------------------------------- /Pods/MMPlaceHolder/README.md: -------------------------------------------------------------------------------- 1 | MMPlaceHolder 2 | ============= 3 | [![Total views](https://sourcegraph.com/api/repos/github.com/adad184/MMPlaceHolder/.counters/views.png)](https://sourcegraph.com/github.com/adad184/MMPlaceHolder) 4 | [![Views in the last 24 hours](https://sourcegraph.com/api/repos/github.com/adad184/MMPlaceHolder/.counters/views-24h.png)](https://sourcegraph.com/github.com/adad184/MMPlaceHolder) 5 | 6 | A drop in solution to set a placeholder or show UIView's size 7 | 8 | [中文介绍](http://adad184.com/2014/08/21/2014-08-21-kai-yuan-xiang-mu-mmplaceholder/) 9 | 10 | you can use it for frame debug 11 | ![demo](https://raw.githubusercontent.com/adad184/MMPlaceHolder/master/Screenshot/screenshot2.PNG) 12 | 13 | or you can use it for size debug 14 | ![show](https://raw.githubusercontent.com/adad184/MMPlaceHolder/master/Screenshot/screenshot1.PNG) 15 | 16 | 17 | Installation 18 | ============ 19 | 20 | The preferred way of installation is via [CocoaPods](http://cocoapods.org). Just add 21 | 22 | ```ruby 23 | pod 'MMPlaceHolder' 24 | ``` 25 | 26 | and run `pod install`. It will install the most recent version of MMPlaceHolder. 27 | 28 | If you would like to use the latest code of MMPlaceHolder use: 29 | 30 | ```ruby 31 | pod 'MMPlaceHolder', :head 32 | ``` 33 | 34 | Usage 35 | =============== 36 | 37 | simply, you only need one line code. 38 | 39 | ```objc 40 | [yourView showPlaceHolder]; 41 | ``` 42 | 43 | 44 | or you can customize youself. 45 | 46 | ```objc 47 | @interface UIView(MMPlaceHolder) 48 | 49 | - (void)showPlaceHolder; 50 | - (void)showPlaceHolderWithAllSubviews; 51 | - (void)showPlaceHolderWithAllSubviews:(NSInteger)maxDepth; 52 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor; 53 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor; 54 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor arrowSize:(CGFloat)arrowSize; 55 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor arrowSize:(CGFloat)arrowSize lineWidth:(CGFloat)lineWidth; 56 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor arrowSize:(CGFloat)arrowSize lineWidth:(CGFloat)lineWidth frameWidth:(CGFloat)frameWidth frameColor:(UIColor*)frameColor; 57 | 58 | - (void)hidePlaceHolder; 59 | - (void)hidePlaceHolderWithAllSubviews; 60 | - (void)removePlaceHolder; 61 | - (void)removePlaceHolderWithAllSubviews; 62 | - (MMPlaceHolder *)getPlaceHolder; 63 | 64 | @end 65 | ``` 66 | 67 | 68 | and you can use the global configuration 69 | 70 | ```objc 71 | @interface MMPlaceHolderConfig : NSObject 72 | 73 | + (MMPlaceHolderConfig*) defaultConfig; 74 | 75 | @property (nonatomic, strong) UIColor *backColor; 76 | @property (nonatomic, assign) CGFloat arrowSize; 77 | @property (nonatomic, strong) UIColor *lineColor; 78 | @property (nonatomic, assign) CGFloat lineWidth; 79 | @property (nonatomic, strong) UIColor *frameColor; 80 | @property (nonatomic, assign) CGFloat frameWidth; 81 | 82 | @property (nonatomic, assign) BOOL showArrow; 83 | @property (nonatomic, assign) BOOL showText; 84 | 85 | 86 | @property (nonatomic, assign) BOOL visible; 87 | @property (nonatomic, assign) BOOL autoDisplay; 88 | @property (nonatomic, strong) NSArray *visibleMemberOfClasses; 89 | @property (nonatomic, strong) NSArray *visibleKindOfClasses; 90 | 91 | @end 92 | ``` 93 | 94 | 95 | Changelog 96 | =============== 97 | 98 | v1.8 now you can hide the system view and keep the interface clean & tidy 99 | 100 | ```objc 101 | 102 | @property (nonatomic, assign) BOOL autoDisplaySystemView; 103 | 104 | ``` 105 | 106 | v1.7 now you can display the specific class while in Autodisplay mode(thx [pull request](https://github.com/adad184/MMPlaceHolder/pull/3) from [@mrdaios](https://github.com/mrdaios)) 107 | 108 | ```objc 109 | 110 | @property (nonatomic, strong) NSArray *visibleMemberOfClasses; 111 | @property (nonatomic, strong) NSArray *visibleKindOfClasses; 112 | 113 | [MMPlaceHolderConfig defaultConfig].visibleMemberOfClasses = @[UIImageView.class]; 114 | [MMPlaceHolderConfig defaultConfig].visibleKindOfClasses = @[UIButton.class]; 115 | 116 | ``` 117 | 118 | v1.6 now you can control the visibility of frame & arrow & text by 119 | 120 | ```objc 121 | 122 | @property (nonatomic, strong) UIColor *frameColor; 123 | @property (nonatomic, assign) CGFloat frameWidth; 124 | 125 | [MMPlaceHolderConfig defaultConfig].showArrow = YES; 126 | [MMPlaceHolderConfig defaultConfig].showText = YES; 127 | ``` 128 | and modified the function `hidePlaceHolder` & add new function `removePlaceHolder` 129 | 130 | ```objc 131 | - (void)removePlaceHolder; 132 | - (void)removePlaceHolderWithAllSubviews; 133 | ``` 134 | most important thing is you can automatic display the placeholder with one line code by 135 | 136 | ```objc 137 | [MMPlaceHolderConfig defaultConfig].autoDisplay = YES; 138 | ``` 139 | 140 | 141 | v1.5 fix hidePlaceHolder bug when subviews shows placeholder 142 | 143 | 144 | v1.4 add a demo project & now you can config the global visability by 145 | 146 | ```objc 147 | [MMPlaceHolderConfig defaultConfig].visible = NO; 148 | ``` 149 | 150 | 151 | v1.3 now you can add placeholders recursively by 152 | 153 | ```objc 154 | - (void)showPlaceHolderWithAllSubviews; 155 | - (void)showPlaceHolderWithAllSubviews:(NSInteger)maxDepth; 156 | - (void)hidePlaceHolderWithAllSubviews; 157 | ``` 158 | 159 | 160 | v1.2 now you can change default configuration by `[MMPlaceHolderConfig defaultConfig]` 161 | 162 | ```objc 163 | [MMPlaceHolderConfig defaultConfig].lineColor = [UIColor whiteColor]; 164 | [MMPlaceHolderConfig defaultConfig].backColor = [UIColor clearColor]; 165 | [MMPlaceHolderConfig defaultConfig].arrowSize = 3; 166 | [MMPlaceHolderConfig defaultConfig].lineWidth = 1; 167 | ``` 168 | 169 | 170 | v1.1 now you can get or remove `MMPlaceHolder` by 171 | 172 | ```objc 173 | - (void)hidePlaceHolder; 174 | - (MMPlaceHolder *)getPlaceHolder; 175 | ``` 176 | 177 | 178 | v1.0 you can custom or simply use it by 179 | 180 | ```objc 181 | - (void)showPlaceHolder; 182 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor; 183 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor; 184 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor arrowSize:(CGFloat)arrowSize ; 185 | - (void)showPlaceHolderWithLineColor:(UIColor*)lineColor backColor:(UIColor*)backColor arrowSize:(CGFloat)arrowSize lineWidth:(CGFloat)lineWidth; 186 | ``` 187 | 188 | 189 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (0.6.1) 3 | - MMPlaceHolder (1.8) 4 | 5 | DEPENDENCIES: 6 | - Masonry 7 | - MMPlaceHolder 8 | 9 | SPEC CHECKSUMS: 10 | Masonry: 4972309f2f134de9dd312f4dc4a21359b50e6caa 11 | MMPlaceHolder: 6dbbd7d0dbaaa556eefbc75b8039fcd9f9cd576a 12 | 13 | COCOAPODS: 0.37.2 14 | -------------------------------------------------------------------------------- /Pods/Masonry/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | /** 131 | * Sets the constraint debug name 132 | */ 133 | - (MASConstraint * (^)(id key))key; 134 | 135 | // NSLayoutConstraint constant Setters 136 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 137 | 138 | /** 139 | * Modifies the NSLayoutConstraint constant, 140 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 141 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 142 | */ 143 | - (void)setInsets:(MASEdgeInsets)insets; 144 | 145 | /** 146 | * Modifies the NSLayoutConstraint constant, 147 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 148 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 149 | */ 150 | - (void)setSizeOffset:(CGSize)sizeOffset; 151 | 152 | /** 153 | * Modifies the NSLayoutConstraint constant, 154 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 155 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 156 | */ 157 | - (void)setCenterOffset:(CGPoint)centerOffset; 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant 161 | */ 162 | - (void)setOffset:(CGFloat)offset; 163 | 164 | 165 | // NSLayoutConstraint Installation support 166 | 167 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 168 | /** 169 | * Whether or not to go through the animator proxy when modifying the constraint 170 | */ 171 | @property (nonatomic, copy, readonly) MASConstraint *animator; 172 | #endif 173 | 174 | /** 175 | * Activates an NSLayoutConstraint if it's supported by an OS. 176 | * Invokes install otherwise. 177 | */ 178 | - (void)activate; 179 | 180 | /** 181 | * Deactivates previously installed/activated NSLayoutConstraint. 182 | */ 183 | - (void)deactivate; 184 | 185 | /** 186 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 187 | */ 188 | - (void)install; 189 | 190 | /** 191 | * Removes previously installed NSLayoutConstraint 192 | */ 193 | - (void)uninstall; 194 | 195 | @end 196 | 197 | 198 | /** 199 | * Convenience auto-boxing macros for MASConstraint methods. 200 | * 201 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 202 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 203 | */ 204 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 205 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 206 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 207 | 208 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 209 | 210 | 211 | #ifdef MAS_SHORTHAND_GLOBALS 212 | 213 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 214 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 215 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 216 | 217 | #define offset(...) mas_offset(__VA_ARGS__) 218 | 219 | #endif 220 | 221 | 222 | @interface MASConstraint (AutoboxingSupport) 223 | 224 | /** 225 | * Aliases to corresponding relation methods (for shorthand macros) 226 | * Also needed to aid autocompletion 227 | */ 228 | - (MASConstraint * (^)(id attr))mas_equalTo; 229 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 230 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 231 | 232 | /** 233 | * A dummy method to aid autocompletion 234 | */ 235 | - (MASConstraint * (^)(id offset))mas_offset; 236 | 237 | @end 238 | -------------------------------------------------------------------------------- /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 | #pragma mark - Abstract 212 | 213 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 214 | 215 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 216 | 217 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 218 | 219 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 220 | 221 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 222 | 223 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 224 | 225 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 226 | 227 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 228 | 229 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 230 | 231 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 232 | 233 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 234 | 235 | #endif 236 | 237 | - (void)activate { MASMethodNotImplemented(); } 238 | 239 | - (void)deactivate { MASMethodNotImplemented(); } 240 | 241 | - (void)install { MASMethodNotImplemented(); } 242 | 243 | - (void)uninstall { MASMethodNotImplemented(); } 244 | 245 | @end 246 | -------------------------------------------------------------------------------- /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 | 26 | /** 27 | * Provides factory methods for creating MASConstraints. 28 | * Constraints are collected until they are ready to be installed 29 | * 30 | */ 31 | @interface MASConstraintMaker : NSObject 32 | 33 | /** 34 | * The following properties return a new MASViewConstraint 35 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 36 | */ 37 | @property (nonatomic, strong, readonly) MASConstraint *left; 38 | @property (nonatomic, strong, readonly) MASConstraint *top; 39 | @property (nonatomic, strong, readonly) MASConstraint *right; 40 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 41 | @property (nonatomic, strong, readonly) MASConstraint *leading; 42 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 43 | @property (nonatomic, strong, readonly) MASConstraint *width; 44 | @property (nonatomic, strong, readonly) MASConstraint *height; 45 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 46 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 47 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 48 | 49 | /** 50 | * Returns a block which creates a new MASCompositeConstraint with the first item set 51 | * to the makers associated view and children corresponding to the set bits in the 52 | * MASAttribute parameter. Combine multiple attributes via binary-or. 53 | */ 54 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 55 | 56 | /** 57 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 58 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 59 | * with the first item set to the makers associated view 60 | */ 61 | @property (nonatomic, strong, readonly) MASConstraint *edges; 62 | 63 | /** 64 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 65 | * which generates the appropriate MASViewConstraint children (width, height) 66 | * with the first item set to the makers associated view 67 | */ 68 | @property (nonatomic, strong, readonly) MASConstraint *size; 69 | 70 | /** 71 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 72 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 73 | * with the first item set to the makers associated view 74 | */ 75 | @property (nonatomic, strong, readonly) MASConstraint *center; 76 | 77 | /** 78 | * Whether or not to check for an existing constraint instead of adding constraint 79 | */ 80 | @property (nonatomic, assign) BOOL updateExisting; 81 | 82 | /** 83 | * Whether or not to remove existing constraints prior to installing 84 | */ 85 | @property (nonatomic, assign) BOOL removeExisting; 86 | 87 | /** 88 | * initialises the maker with a default view 89 | * 90 | * @param view any MASConstrait are created with this view as the first item 91 | * 92 | * @return a new MASConstraintMaker 93 | */ 94 | - (id)initWithView:(MAS_VIEW *)view; 95 | 96 | /** 97 | * Calls install method on any MASConstraints which have been created by this maker 98 | * 99 | * @return an array of all the installed MASConstraints 100 | */ 101 | - (NSArray *)install; 102 | 103 | - (MASConstraint * (^)(dispatch_block_t))group; 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /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 | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX | MASAttributeCenterY | MASAttributeBaseline; 79 | 80 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); 81 | 82 | NSMutableArray *attributes = [NSMutableArray array]; 83 | 84 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; 85 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; 86 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; 87 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; 88 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; 89 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; 90 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; 91 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; 92 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; 93 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; 94 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; 95 | 96 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; 97 | 98 | for (MASViewAttribute *a in attributes) { 99 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; 100 | } 101 | 102 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 103 | constraint.delegate = self; 104 | [self.constraints addObject:constraint]; 105 | return constraint; 106 | } 107 | 108 | #pragma mark - standard Attributes 109 | 110 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 111 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; 112 | } 113 | 114 | - (MASConstraint *)left { 115 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 116 | } 117 | 118 | - (MASConstraint *)top { 119 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 120 | } 121 | 122 | - (MASConstraint *)right { 123 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 124 | } 125 | 126 | - (MASConstraint *)bottom { 127 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 128 | } 129 | 130 | - (MASConstraint *)leading { 131 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 132 | } 133 | 134 | - (MASConstraint *)trailing { 135 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 136 | } 137 | 138 | - (MASConstraint *)width { 139 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 140 | } 141 | 142 | - (MASConstraint *)height { 143 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 144 | } 145 | 146 | - (MASConstraint *)centerX { 147 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 148 | } 149 | 150 | - (MASConstraint *)centerY { 151 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 152 | } 153 | 154 | - (MASConstraint *)baseline { 155 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 156 | } 157 | 158 | - (MASConstraint *(^)(MASAttribute))attributes { 159 | return ^(MASAttribute attrs){ 160 | return [self addConstraintWithAttributes:attrs]; 161 | }; 162 | } 163 | 164 | 165 | #pragma mark - composite Attributes 166 | 167 | - (MASConstraint *)edges { 168 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; 169 | } 170 | 171 | - (MASConstraint *)size { 172 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; 173 | } 174 | 175 | - (MASConstraint *)center { 176 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; 177 | } 178 | 179 | #pragma mark - grouping 180 | 181 | - (MASConstraint *(^)(dispatch_block_t group))group { 182 | return ^id(dispatch_block_t group) { 183 | NSInteger previousCount = self.constraints.count; 184 | group(); 185 | 186 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; 187 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 188 | constraint.delegate = self; 189 | return constraint; 190 | }; 191 | } 192 | 193 | @end 194 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | #if TARGET_OS_IPHONE 12 | 13 | #import 14 | #define MAS_VIEW UIView 15 | #define MASEdgeInsets UIEdgeInsets 16 | 17 | typedef UILayoutPriority MASLayoutPriority; 18 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 19 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 20 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 21 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 22 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 23 | 24 | #elif TARGET_OS_MAC 25 | 26 | #import 27 | #define MAS_VIEW NSView 28 | #define MASEdgeInsets NSEdgeInsets 29 | 30 | typedef NSLayoutPriority MASLayoutPriority; 31 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 32 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 33 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 34 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 35 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 38 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 39 | 40 | #endif 41 | 42 | /** 43 | * Allows you to attach keys to objects matching the variable names passed. 44 | * 45 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 46 | * 47 | * is equivalent to: 48 | * 49 | * MASAttachKeys(view1, view2); 50 | */ 51 | #define MASAttachKeys(...) \ 52 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 53 | for (id key in keyPairs.allKeys) { \ 54 | id obj = keyPairs[key]; \ 55 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 56 | @"Cannot attach mas_key to %@", obj); \ 57 | [obj setMas_key:key]; \ 58 | } 59 | 60 | /** 61 | * Used to create object hashes 62 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 63 | */ 64 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 65 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 66 | 67 | /** 68 | * Given a scalar or struct value, wraps it in NSValue 69 | * Based on EXPObjectify: https://github.com/specta/expecta 70 | */ 71 | static inline id _MASBoxValue(const char *type, ...) { 72 | va_list v; 73 | va_start(v, type); 74 | id obj = nil; 75 | if (strcmp(type, @encode(id)) == 0) { 76 | id actual = va_arg(v, id); 77 | obj = actual; 78 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 79 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 80 | obj = [NSValue value:&actual withObjCType:type]; 81 | } else if (strcmp(type, @encode(CGSize)) == 0) { 82 | CGSize actual = (CGSize)va_arg(v, CGSize); 83 | obj = [NSValue value:&actual withObjCType:type]; 84 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 85 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 86 | obj = [NSValue value:&actual withObjCType:type]; 87 | } else if (strcmp(type, @encode(double)) == 0) { 88 | double actual = (double)va_arg(v, double); 89 | obj = [NSNumber numberWithDouble:actual]; 90 | } else if (strcmp(type, @encode(float)) == 0) { 91 | float actual = (float)va_arg(v, double); 92 | obj = [NSNumber numberWithFloat:actual]; 93 | } else if (strcmp(type, @encode(int)) == 0) { 94 | int actual = (int)va_arg(v, int); 95 | obj = [NSNumber numberWithInt:actual]; 96 | } else if (strcmp(type, @encode(long)) == 0) { 97 | long actual = (long)va_arg(v, long); 98 | obj = [NSNumber numberWithLong:actual]; 99 | } else if (strcmp(type, @encode(long long)) == 0) { 100 | long long actual = (long long)va_arg(v, long long); 101 | obj = [NSNumber numberWithLongLong:actual]; 102 | } else if (strcmp(type, @encode(short)) == 0) { 103 | short actual = (short)va_arg(v, int); 104 | obj = [NSNumber numberWithShort:actual]; 105 | } else if (strcmp(type, @encode(char)) == 0) { 106 | char actual = (char)va_arg(v, int); 107 | obj = [NSNumber numberWithChar:actual]; 108 | } else if (strcmp(type, @encode(bool)) == 0) { 109 | bool actual = (bool)va_arg(v, int); 110 | obj = [NSNumber numberWithBool:actual]; 111 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 112 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 113 | obj = [NSNumber numberWithUnsignedChar:actual]; 114 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 115 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 116 | obj = [NSNumber numberWithUnsignedInt:actual]; 117 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 118 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 119 | obj = [NSNumber numberWithUnsignedLong:actual]; 120 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 121 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 122 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 123 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 124 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 125 | obj = [NSNumber numberWithUnsignedShort:actual]; 126 | } 127 | va_end(v); 128 | return obj; 129 | } 130 | 131 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 132 | -------------------------------------------------------------------------------- /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 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The attribute which the reciever relates to 24 | */ 25 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 26 | 27 | /** 28 | * The designated initializer. 29 | */ 30 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 31 | 32 | /** 33 | * Determine whether the layoutAttribute is a size attribute 34 | * 35 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 36 | */ 37 | - (BOOL)isSizeAttribute; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /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 = [super init]; 15 | if (!self) return nil; 16 | 17 | _view = view; 18 | _layoutAttribute = layoutAttribute; 19 | 20 | return self; 21 | } 22 | 23 | - (BOOL)isSizeAttribute { 24 | return self.layoutAttribute == NSLayoutAttributeWidth 25 | || self.layoutAttribute == NSLayoutAttributeHeight; 26 | } 27 | 28 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 29 | if ([viewAttribute isKindOfClass:self.class]) { 30 | return self.view == viewAttribute.view 31 | && self.layoutAttribute == viewAttribute.layoutAttribute; 32 | } 33 | return [super isEqual:viewAttribute]; 34 | } 35 | 36 | - (NSUInteger)hash { 37 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 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.secondViewAttribute = attr; 179 | [children addObject:viewConstraint]; 180 | } 181 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 182 | compositeConstraint.delegate = self.delegate; 183 | [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint]; 184 | return compositeConstraint; 185 | } else { 186 | NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation"); 187 | self.layoutRelation = relation; 188 | self.secondViewAttribute = attribute; 189 | return self; 190 | } 191 | }; 192 | } 193 | 194 | #pragma mark - Semantic properties 195 | 196 | - (MASConstraint *)with { 197 | return self; 198 | } 199 | 200 | - (MASConstraint *)and { 201 | return self; 202 | } 203 | 204 | #pragma mark - attribute chaining 205 | 206 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 207 | NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation"); 208 | 209 | return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 210 | } 211 | 212 | #pragma mark - Animator proxy 213 | 214 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 215 | 216 | - (MASConstraint *)animator { 217 | self.useAnimator = YES; 218 | return self; 219 | } 220 | 221 | #endif 222 | 223 | #pragma mark - debug helpers 224 | 225 | - (MASConstraint * (^)(id))key { 226 | return ^id(id key) { 227 | self.mas_key = key; 228 | return self; 229 | }; 230 | } 231 | 232 | #pragma mark - NSLayoutConstraint constant setters 233 | 234 | - (void)setInsets:(MASEdgeInsets)insets { 235 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 236 | switch (layoutAttribute) { 237 | case NSLayoutAttributeLeft: 238 | self.layoutConstant = insets.left; 239 | break; 240 | case NSLayoutAttributeTop: 241 | self.layoutConstant = insets.top; 242 | break; 243 | case NSLayoutAttributeBottom: 244 | self.layoutConstant = -insets.bottom; 245 | break; 246 | case NSLayoutAttributeRight: 247 | self.layoutConstant = -insets.right; 248 | break; 249 | default: 250 | break; 251 | } 252 | } 253 | 254 | - (void)setOffset:(CGFloat)offset { 255 | self.layoutConstant = offset; 256 | } 257 | 258 | - (void)setSizeOffset:(CGSize)sizeOffset { 259 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 260 | switch (layoutAttribute) { 261 | case NSLayoutAttributeWidth: 262 | self.layoutConstant = sizeOffset.width; 263 | break; 264 | case NSLayoutAttributeHeight: 265 | self.layoutConstant = sizeOffset.height; 266 | break; 267 | default: 268 | break; 269 | } 270 | } 271 | 272 | - (void)setCenterOffset:(CGPoint)centerOffset { 273 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 274 | switch (layoutAttribute) { 275 | case NSLayoutAttributeCenterX: 276 | self.layoutConstant = centerOffset.x; 277 | break; 278 | case NSLayoutAttributeCenterY: 279 | self.layoutConstant = centerOffset.y; 280 | break; 281 | default: 282 | break; 283 | } 284 | } 285 | 286 | #pragma mark - MASConstraint 287 | 288 | - (void)activate { 289 | if ([self supportsActiveProperty] && self.layoutConstraint) { 290 | if (self.hasBeenInstalled) { 291 | return; 292 | } 293 | self.layoutConstraint.active = YES; 294 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; 295 | } else { 296 | [self install]; 297 | } 298 | } 299 | 300 | - (void)deactivate { 301 | if ([self supportsActiveProperty]) { 302 | self.layoutConstraint.active = NO; 303 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 304 | } else { 305 | [self uninstall]; 306 | } 307 | } 308 | 309 | - (void)install { 310 | if (self.hasBeenInstalled) { 311 | return; 312 | } 313 | 314 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.view; 315 | 316 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute; 317 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.view; 318 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute; 319 | 320 | // alignment attributes must have a secondViewAttribute 321 | // therefore we assume that is refering to superview 322 | // eg make.left.equalTo(@10) 323 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) { 324 | secondLayoutItem = firstLayoutItem.superview; 325 | secondLayoutAttribute = firstLayoutAttribute; 326 | } 327 | 328 | MASLayoutConstraint *layoutConstraint 329 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem 330 | attribute:firstLayoutAttribute 331 | relatedBy:self.layoutRelation 332 | toItem:secondLayoutItem 333 | attribute:secondLayoutAttribute 334 | multiplier:self.layoutMultiplier 335 | constant:self.layoutConstant]; 336 | 337 | layoutConstraint.priority = self.layoutPriority; 338 | layoutConstraint.mas_key = self.mas_key; 339 | 340 | if (secondLayoutItem) { 341 | MAS_VIEW *closestCommonSuperview = [firstLayoutItem mas_closestCommonSuperview:secondLayoutItem]; 342 | NSAssert(closestCommonSuperview, 343 | @"couldn't find a common superview for %@ and %@", 344 | firstLayoutItem, secondLayoutItem); 345 | self.installedView = closestCommonSuperview; 346 | } else { 347 | self.installedView = firstLayoutItem; 348 | } 349 | 350 | 351 | MASLayoutConstraint *existingConstraint = nil; 352 | if (self.updateExisting) { 353 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint]; 354 | } 355 | if (existingConstraint) { 356 | // just update the constant 357 | existingConstraint.constant = layoutConstraint.constant; 358 | self.layoutConstraint = existingConstraint; 359 | } else { 360 | [self.installedView addConstraint:layoutConstraint]; 361 | self.layoutConstraint = layoutConstraint; 362 | } 363 | 364 | [firstLayoutItem.mas_installedConstraints addObject:self]; 365 | } 366 | 367 | - (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint { 368 | // check if any constraints are the same apart from the only mutable property constant 369 | 370 | // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints 371 | // and they are likely to be added first. 372 | for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) { 373 | if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue; 374 | if (existingConstraint.firstItem != layoutConstraint.firstItem) continue; 375 | if (existingConstraint.secondItem != layoutConstraint.secondItem) continue; 376 | if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue; 377 | if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue; 378 | if (existingConstraint.relation != layoutConstraint.relation) continue; 379 | if (existingConstraint.multiplier != layoutConstraint.multiplier) continue; 380 | if (existingConstraint.priority != layoutConstraint.priority) continue; 381 | 382 | return (id)existingConstraint; 383 | } 384 | return nil; 385 | } 386 | 387 | - (void)uninstall { 388 | [self.installedView removeConstraint:self.layoutConstraint]; 389 | self.layoutConstraint = nil; 390 | self.installedView = nil; 391 | 392 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 393 | } 394 | 395 | @end 396 | -------------------------------------------------------------------------------- /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 "MASUtilities.h" 10 | #import "View+MASAdditions.h" 11 | #import "View+MASShorthandAdditions.h" 12 | #import "NSArray+MASAdditions.h" 13 | #import "NSArray+MASShorthandAdditions.h" 14 | #import "MASConstraint.h" 15 | #import "MASCompositeConstraint.h" 16 | #import "MASViewAttribute.h" 17 | #import "MASViewConstraint.h" 18 | #import "MASConstraintMaker.h" 19 | #import "MASLayoutConstraint.h" 20 | #import "NSLayoutConstraint+MASDebugAdditions.h" 21 | -------------------------------------------------------------------------------- /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 | @interface NSArray (MASAdditions) 14 | 15 | /** 16 | * Creates a MASConstraintMaker with each view in the callee. 17 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 18 | * 19 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 20 | * 21 | * @return Array of created MASConstraints 22 | */ 23 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 24 | 25 | /** 26 | * Creates a MASConstraintMaker with each view in the callee. 27 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 28 | * If an existing constraint exists then it will be updated instead. 29 | * 30 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 31 | * 32 | * @return Array of created/updated MASConstraints 33 | */ 34 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 35 | 36 | /** 37 | * Creates a MASConstraintMaker with each view in the callee. 38 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 39 | * All constraints previously installed for the views will be removed. 40 | * 41 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 42 | * 43 | * @return Array of created/updated MASConstraints 44 | */ 45 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /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 | @end 42 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 48 | }); 49 | return descriptionMap; 50 | } 51 | 52 | 53 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 54 | static dispatch_once_t once; 55 | static NSDictionary *descriptionMap; 56 | dispatch_once(&once, ^{ 57 | #if TARGET_OS_IPHONE 58 | descriptionMap = @{ 59 | @(MASLayoutPriorityDefaultHigh) : @"high", 60 | @(MASLayoutPriorityDefaultLow) : @"low", 61 | @(MASLayoutPriorityDefaultMedium) : @"medium", 62 | @(MASLayoutPriorityRequired) : @"required", 63 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 64 | }; 65 | #elif TARGET_OS_MAC 66 | descriptionMap = @{ 67 | @(MASLayoutPriorityDefaultHigh) : @"high", 68 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 69 | @(MASLayoutPriorityDefaultMedium) : @"medium", 70 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 71 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 72 | @(MASLayoutPriorityDefaultLow) : @"low", 73 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 74 | @(MASLayoutPriorityRequired) : @"required", 75 | }; 76 | #endif 77 | }); 78 | return descriptionMap; 79 | } 80 | 81 | #pragma mark - description override 82 | 83 | + (NSString *)descriptionForObject:(id)obj { 84 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 85 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 86 | } 87 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 88 | } 89 | 90 | - (NSString *)description { 91 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 92 | 93 | [description appendString:[self.class descriptionForObject:self]]; 94 | 95 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 96 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 97 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.firstAttribute)]]; 98 | } 99 | 100 | [description appendFormat:@" %@", [self.class.layoutRelationDescriptionsByValue objectForKey:@(self.relation)]]; 101 | 102 | if (self.secondItem) { 103 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 104 | } 105 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 106 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.secondAttribute)]]; 107 | } 108 | 109 | if (self.multiplier != 1) { 110 | [description appendFormat:@" * %g", self.multiplier]; 111 | } 112 | 113 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 114 | [description appendFormat:@" %g", self.constant]; 115 | } else { 116 | if (self.constant) { 117 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 118 | } 119 | } 120 | 121 | if (self.priority != MASLayoutPriorityRequired) { 122 | [description appendFormat:@" ^%@", [self.class.layoutPriorityDescriptionsByValue objectForKey:@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 123 | } 124 | 125 | [description appendString:@">"]; 126 | return description; 127 | } 128 | 129 | @end 130 | -------------------------------------------------------------------------------- /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 | /** 36 | * a key to associate with this view 37 | */ 38 | @property (nonatomic, strong) id mas_key; 39 | 40 | /** 41 | * Finds the closest common superview between this view and another view 42 | * 43 | * @param view other view 44 | * 45 | * @return returns nil if common superview could not be found 46 | */ 47 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 48 | 49 | /** 50 | * Creates a MASConstraintMaker with the callee view. 51 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 52 | * 53 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 54 | * 55 | * @return Array of created MASConstraints 56 | */ 57 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 58 | 59 | /** 60 | * Creates a MASConstraintMaker with the callee view. 61 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 62 | * If an existing constraint exists then it will be updated instead. 63 | * 64 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 65 | * 66 | * @return Array of created/updated MASConstraints 67 | */ 68 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 69 | 70 | /** 71 | * Creates a MASConstraintMaker with the callee view. 72 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 73 | * All constraints previously installed for the view will be removed. 74 | * 75 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 76 | * 77 | * @return Array of created/updated MASConstraints 78 | */ 79 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /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 | #pragma mark - associated properties 91 | 92 | - (id)mas_key { 93 | return objc_getAssociatedObject(self, @selector(mas_key)); 94 | } 95 | 96 | - (void)setMas_key:(id)key { 97 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 98 | } 99 | 100 | #pragma mark - heirachy 101 | 102 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 103 | MAS_VIEW *closestCommonSuperview = nil; 104 | 105 | MAS_VIEW *secondViewSuperview = view; 106 | while (!closestCommonSuperview && secondViewSuperview) { 107 | MAS_VIEW *firstViewSuperview = self; 108 | while (!closestCommonSuperview && firstViewSuperview) { 109 | if (secondViewSuperview == firstViewSuperview) { 110 | closestCommonSuperview = secondViewSuperview; 111 | } 112 | firstViewSuperview = firstViewSuperview.superview; 113 | } 114 | secondViewSuperview = secondViewSuperview.superview; 115 | } 116 | return closestCommonSuperview; 117 | } 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /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 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 33 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 34 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 35 | 36 | @end 37 | 38 | #define MAS_ATTR_FORWARD(attr) \ 39 | - (MASViewAttribute *)attr { \ 40 | return [self mas_##attr]; \ 41 | } 42 | 43 | @implementation MAS_VIEW (MASShorthandAdditions) 44 | 45 | MAS_ATTR_FORWARD(top); 46 | MAS_ATTR_FORWARD(left); 47 | MAS_ATTR_FORWARD(bottom); 48 | MAS_ATTR_FORWARD(right); 49 | MAS_ATTR_FORWARD(leading); 50 | MAS_ATTR_FORWARD(trailing); 51 | MAS_ATTR_FORWARD(width); 52 | MAS_ATTR_FORWARD(height); 53 | MAS_ATTR_FORWARD(centerX); 54 | MAS_ATTR_FORWARD(centerY); 55 | MAS_ATTR_FORWARD(baseline); 56 | 57 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 58 | return [self mas_attribute]; 59 | } 60 | 61 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 62 | return [self mas_makeConstraints:block]; 63 | } 64 | 65 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 66 | return [self mas_updateConstraints:block]; 67 | } 68 | 69 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 70 | return [self mas_remakeConstraints:block]; 71 | } 72 | 73 | @end 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Pods/Masonry/README.md: -------------------------------------------------------------------------------- 1 | #Masonry [![Build Status](https://travis-ci.org/Masonry/Masonry.svg?branch=master)](https://travis-ci.org/Masonry/Masonry) [![Coverage Status](https://img.shields.io/coveralls/Masonry/Masonry.svg?style=flat-square)](https://coveralls.io/r/Masonry/Masonry) 2 | 3 | Masonry is a light-weight layout framework which wraps AutoLayout with a nicer syntax. Masonry has its own layout DSL which provides a chainable way of describing your NSLayoutConstraints which results in layout code that is more concise and readable. 4 | Masonry supports iOS and Mac OS X. 5 | 6 | For examples take a look at the **Masonry iOS Examples** project in the Masonry workspace. You will need to run `pod install` after downloading. 7 | 8 | ## What's wrong with NSLayoutConstraints? 9 | 10 | Under the hood Auto Layout is a powerful and flexible way of organising and laying out your views. However creating constraints from code is verbose and not very descriptive. 11 | Imagine a simple example in which you want to have a view fill its superview but inset by 10 pixels on every side 12 | ```obj-c 13 | UIView *superview = self; 14 | 15 | UIView *view1 = [[UIView alloc] init]; 16 | view1.translatesAutoresizingMaskIntoConstraints = NO; 17 | view1.backgroundColor = [UIColor greenColor]; 18 | [superview addSubview:view1]; 19 | 20 | UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10); 21 | 22 | [superview addConstraints:@[ 23 | 24 | //view1 constraints 25 | [NSLayoutConstraint constraintWithItem:view1 26 | attribute:NSLayoutAttributeTop 27 | relatedBy:NSLayoutRelationEqual 28 | toItem:superview 29 | attribute:NSLayoutAttributeTop 30 | multiplier:1.0 31 | constant:padding.top], 32 | 33 | [NSLayoutConstraint constraintWithItem:view1 34 | attribute:NSLayoutAttributeLeft 35 | relatedBy:NSLayoutRelationEqual 36 | toItem:superview 37 | attribute:NSLayoutAttributeLeft 38 | multiplier:1.0 39 | constant:padding.left], 40 | 41 | [NSLayoutConstraint constraintWithItem:view1 42 | attribute:NSLayoutAttributeBottom 43 | relatedBy:NSLayoutRelationEqual 44 | toItem:superview 45 | attribute:NSLayoutAttributeBottom 46 | multiplier:1.0 47 | constant:-padding.bottom], 48 | 49 | [NSLayoutConstraint constraintWithItem:view1 50 | attribute:NSLayoutAttributeRight 51 | relatedBy:NSLayoutRelationEqual 52 | toItem:superview 53 | attribute:NSLayoutAttributeRight 54 | multiplier:1 55 | constant:-padding.right], 56 | 57 | ]]; 58 | ``` 59 | Even with such a simple example the code needed is quite verbose and quickly becomes unreadable when you have more than 2 or 3 views. 60 | Another option is to use Visual Format Language (VFL), which is a bit less long winded. 61 | However the ASCII type syntax has its own pitfalls and its also a bit harder to animate as `NSLayoutConstraint constraintsWithVisualFormat:` returns an array. 62 | 63 | ## Prepare to meet your Maker! 64 | 65 | Heres the same constraints created using MASConstraintMaker 66 | 67 | ```obj-c 68 | UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10); 69 | 70 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) { 71 | make.top.equalTo(superview.mas_top).with.offset(padding.top); //with is an optional semantic filler 72 | make.left.equalTo(superview.mas_left).with.offset(padding.left); 73 | make.bottom.equalTo(superview.mas_bottom).with.offset(-padding.bottom); 74 | make.right.equalTo(superview.mas_right).with.offset(-padding.right); 75 | }]; 76 | ``` 77 | Or even shorter 78 | 79 | ```obj-c 80 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) { 81 | make.edges.equalTo(superview).with.insets(padding); 82 | }]; 83 | ``` 84 | 85 | Also note in the first example we had to add the constraints to the superview `[superview addConstraints:...`. 86 | Masonry however will automagically add constraints to the appropriate view. 87 | 88 | Masonry will also call `view1.translatesAutoresizingMaskIntoConstraints = NO;` for you. 89 | 90 | ## Not all things are created equal 91 | 92 | > `.equalTo` equivalent to **NSLayoutRelationEqual** 93 | 94 | > `.lessThanOrEqualTo` equivalent to **NSLayoutRelationLessThanOrEqual** 95 | 96 | > `.greaterThanOrEqualTo` equivalent to **NSLayoutRelationGreaterThanOrEqual** 97 | 98 | These three equality constraints accept one argument which can be any of the following: 99 | 100 | #### 1. MASViewAttribute 101 | 102 | ```obj-c 103 | make.centerX.lessThanOrEqualTo(view2.mas_left); 104 | ``` 105 | 106 | MASViewAttribute | NSLayoutAttribute 107 | ------------------------- | -------------------------- 108 | view.mas_left | NSLayoutAttributeLeft 109 | view.mas_right | NSLayoutAttributeRight 110 | view.mas_top | NSLayoutAttributeTop 111 | view.mas_bottom | NSLayoutAttributeBottom 112 | view.mas_leading | NSLayoutAttributeLeading 113 | view.mas_trailing | NSLayoutAttributeTrailing 114 | view.mas_width | NSLayoutAttributeWidth 115 | view.mas_height | NSLayoutAttributeHeight 116 | view.mas_centerX | NSLayoutAttributeCenterX 117 | view.mas_centerY | NSLayoutAttributeCenterY 118 | view.mas_baseline | NSLayoutAttributeBaseline 119 | 120 | #### 2. UIView/NSView 121 | 122 | if you want view.left to be greater than or equal to label.left : 123 | ```obj-c 124 | //these two constraints are exactly the same 125 | make.left.greaterThanOrEqualTo(label); 126 | make.left.greaterThanOrEqualTo(label.mas_left); 127 | ``` 128 | 129 | #### 3. NSNumber 130 | 131 | Auto Layout allows width and height to be set to constant values. 132 | if you want to set view to have a minimum and maximum width you could pass a number to the equality blocks: 133 | ```obj-c 134 | //width >= 200 && width <= 400 135 | make.width.greaterThanOrEqualTo(@200); 136 | make.width.lessThanOrEqualTo(@400) 137 | ``` 138 | 139 | However Auto Layout does not allow alignment attributes such as left, right, centerY etc to be set to constant values. 140 | So if you pass a NSNumber for these attributes Masonry will turn these into constraints relative to the view’s superview ie: 141 | ```obj-c 142 | //creates view.left = view.superview.left + 10 143 | make.left.lessThanOrEqualTo(@10) 144 | ``` 145 | 146 | Instead of using NSNumber, you can use primitives and structs to build your constraints, like so: 147 | ```obj-c 148 | make.top.mas_equalTo(42); 149 | make.height.mas_equalTo(20); 150 | make.size.mas_equalTo(CGSizeMake(50, 100)); 151 | make.edges.mas_equalTo(UIEdgeInsetsMake(10, 0, 10, 0)); 152 | make.left.mas_equalTo(view).mas_offset(UIEdgeInsetsMake(10, 0, 10, 0)); 153 | ``` 154 | 155 | By default, macros which support [autoboxing](https://en.wikipedia.org/wiki/Autoboxing#Autoboxing) are prefixed with `mas_`. Unprefixed versions are available by defining `MAS_SHORTHAND_GLOBALS` before importing Masonry. 156 | 157 | #### 4. NSArray 158 | 159 | An array of a mixture of any of the previous types 160 | ```obj-c 161 | make.height.equalTo(@[view1.mas_height, view2.mas_height]); 162 | make.height.equalTo(@[view1, view2]); 163 | make.left.equalTo(@[view1, @100, view3.right]); 164 | ```` 165 | 166 | ## Learn to prioritize 167 | 168 | > `.prority` allows you to specify an exact priority 169 | 170 | > `.priorityHigh` equivalent to **UILayoutPriorityDefaultHigh** 171 | 172 | > `.priorityMedium` is half way between high and low 173 | 174 | > `.priorityLow` equivalent to **UILayoutPriorityDefaultLow** 175 | 176 | Priorities are can be tacked on to the end of a constraint chain like so: 177 | ```obj-c 178 | make.left.greaterThanOrEqualTo(label.mas_left).with.priorityLow(); 179 | 180 | make.top.equalTo(label.mas_top).with.priority(600); 181 | ``` 182 | 183 | ## Composition, composition, composition 184 | 185 | Masonry also gives you a few convenience methods which create multiple constraints at the same time. These are called MASCompositeConstraints 186 | 187 | #### edges 188 | 189 | ```obj-c 190 | // make top, left, bottom, right equal view2 191 | make.edges.equalTo(view2); 192 | 193 | // make top = superview.top + 5, left = superview.left + 10, 194 | // bottom = superview.bottom - 15, right = superview.right - 20 195 | make.edges.equalTo(superview).insets(UIEdgeInsetsMake(5, 10, 15, 20)) 196 | ``` 197 | 198 | #### size 199 | 200 | ```obj-c 201 | // make width and height greater than or equal to titleLabel 202 | make.size.greaterThanOrEqualTo(titleLabel) 203 | 204 | // make width = superview.width + 100, height = superview.height - 50 205 | make.size.equalTo(superview).sizeOffset(CGSizeMake(100, -50)) 206 | ``` 207 | 208 | #### center 209 | ```obj-c 210 | // make centerX and centerY = button1 211 | make.center.equalTo(button1) 212 | 213 | // make centerX = superview.centerX - 5, centerY = superview.centerY + 10 214 | make.center.equalTo(superview).centerOffset(CGPointMake(-5, 10)) 215 | ``` 216 | 217 | You can chain view attributes for increased readability: 218 | 219 | ```obj-c 220 | // All edges but the top should equal those of the superview 221 | make.left.right.and.bottom.equalTo(superview); 222 | make.top.equalTo(otherView); 223 | ``` 224 | 225 | ## Hold on for dear life 226 | 227 | Sometimes you need modify existing constraints in order to animate or remove/replace constraints. 228 | In Masonry there are a few different approaches to updating constraints. 229 | 230 | #### 1. References 231 | You can hold on to a reference of a particular constraint by assigning the result of a constraint make expression to a local variable or a class property. 232 | You could also reference multiple constraints by storing them away in an array. 233 | 234 | ```obj-c 235 | // in public/private interface 236 | @property (nonatomic, strong) MASConstraint *topConstraint; 237 | 238 | ... 239 | 240 | // when making constraints 241 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) { 242 | self.topConstraint = make.top.equalTo(superview.mas_top).with.offset(padding.top); 243 | make.left.equalTo(superview.mas_left).with.offset(padding.left); 244 | }]; 245 | 246 | ... 247 | // then later you can call 248 | [self.topConstraint uninstall]; 249 | ``` 250 | 251 | #### 2. mas_updateConstraints 252 | Alternatively if you are only updating the constant value of the constraint you can use the convience method `mas_updateConstraints` instead of `mas_makeConstraints` 253 | 254 | ```obj-c 255 | // this is Apple's recommended place for adding/updating constraints 256 | // this method can get called multiple times in response to setNeedsUpdateConstraints 257 | // which can be called by UIKit internally or in your code if you need to trigger an update to your constraints 258 | - (void)updateConstraints { 259 | [self.growingButton mas_updateConstraints:^(MASConstraintMaker *make) { 260 | make.center.equalTo(self); 261 | make.width.equalTo(@(self.buttonSize.width)).priorityLow(); 262 | make.height.equalTo(@(self.buttonSize.height)).priorityLow(); 263 | make.width.lessThanOrEqualTo(self); 264 | make.height.lessThanOrEqualTo(self); 265 | }]; 266 | 267 | //according to apple super should be called at end of method 268 | [super updateConstraints]; 269 | } 270 | ``` 271 | 272 | ### 3. mas_remakeConstraints 273 | `mas_updateConstraints` is useful for updating a set of constraints, but doing anything beyond updating constant values can get exhausting. That's where `mas_remakeConstraints` comes in. 274 | 275 | `mas_remakeConstraints` is similar to `mas_updateConstraints`, but instead of updating constant values, it will remove all of its contraints before installing them again. This lets you provide different constraints without having to keep around references to ones which you want to remove. 276 | 277 | ```obj-c 278 | - (void)changeButtonPosition { 279 | [self.button mas_remakeConstraints:^(MASConstraintMaker *make) { 280 | make.size.equalTo(self.buttonSize); 281 | 282 | if (topLeft) { 283 | make.top.and.left.offset(10); 284 | } else { 285 | make.bottom.and.right.offset(-10); 286 | } 287 | }]; 288 | } 289 | ``` 290 | 291 | You can find more detailed examples of all three approaches in the **Masonry iOS Examples** project. 292 | 293 | ## When the ^&*!@ hits the fan! 294 | 295 | Laying out your views doesn't always goto plan. So when things literally go pear shaped, you don't want to be looking at console output like this: 296 | 297 | ```obj-c 298 | Unable to simultaneously satisfy constraints.....blah blah blah.... 299 | ( 300 | "=5000)]>", 301 | "", 302 | "", 303 | "" 304 | ) 305 | 306 | Will attempt to recover by breaking constraint 307 | =5000)]> 308 | ``` 309 | 310 | Masonry adds a category to NSLayoutConstraint which overrides the default implementation of `- (NSString *)description`. 311 | Now you can give meaningful names to views and constraints, and also easily pick out the constraints created by Masonry. 312 | 313 | which means your console output can now look like this: 314 | 315 | ```obj-c 316 | Unable to simultaneously satisfy constraints......blah blah blah.... 317 | ( 318 | "", 319 | "= 5000>", 320 | "", 321 | "" 322 | ) 323 | 324 | Will attempt to recover by breaking constraint 325 | = 5000> 326 | ``` 327 | 328 | For an example of how to set this up take a look at the **Masonry iOS Examples** project in the Masonry workspace. 329 | 330 | ## Installation 331 | Use the [orsome](http://www.youtube.com/watch?v=YaIZF8uUTtk) [CocoaPods](http://github.com/CocoaPods/CocoaPods). 332 | 333 | In your Podfile 334 | >`pod 'Masonry'` 335 | 336 | If you want to use masonry without all those pesky 'mas_' prefixes. Add #define MAS_SHORTHAND to your prefix.pch before importing Masonry 337 | >`#define MAS_SHORTHAND` 338 | 339 | Get busy Masoning 340 | >`#import "Masonry.h"` 341 | 342 | ## Code Snippets 343 | 344 | Copy the included code snippets to ``~/Library/Developer/Xcode/UserData/CodeSnippets`` to write your masonry blocks at lightning speed! 345 | 346 | `mas_make` -> `[ mas_makeConstraints:^(MASConstraintMaker *make){}];` 347 | 348 | `mas_update` -> `[ mas_updateConstraints:^(MASConstraintMaker *make){}];` 349 | 350 | `mas_remake` -> `[ mas_remakeConstraints:^(MASConstraintMaker *make){}];` 351 | 352 | ## Features 353 | * Not limited to subset of Auto Layout. Anything NSLayoutConstraint can do, Masonry can do too! 354 | * Great debug support, give your views and constraints meaningful names. 355 | * Constraints read like sentences. 356 | * No crazy macro magic. Masonry won't pollute the global namespace with macros. 357 | * Not string or dictionary based and hence you get compile time checking. 358 | 359 | ## TODO 360 | * Eye candy 361 | * Mac example project 362 | * More tests and examples 363 | 364 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell-MMPlaceHolder/Pods-Demo-complex-cell-MMPlaceHolder-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-Demo-complex-cell-MMPlaceHolder.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MMPlaceHolder" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MMPlaceHolder" "${PODS_ROOT}/Headers/Public/Masonry" 4 | OTHER_LDFLAGS = -ObjC 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell-MMPlaceHolder/Pods-Demo-complex-cell-MMPlaceHolder-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Demo_complex_cell_MMPlaceHolder : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Demo_complex_cell_MMPlaceHolder 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell-MMPlaceHolder/Pods-Demo-complex-cell-MMPlaceHolder-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-Demo-complex-cell-environment.h" 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell-MMPlaceHolder/Pods-Demo-complex-cell-MMPlaceHolder.xcconfig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adad184/DemoComplexCell/fdc74d6fbe7c3c5b59a744faba1fe84ea7e9ff92/Pods/Target Support Files/Pods-Demo-complex-cell-MMPlaceHolder/Pods-Demo-complex-cell-MMPlaceHolder.xcconfig -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell-Masonry/Pods-Demo-complex-cell-Masonry-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-Demo-complex-cell-Masonry.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Masonry" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MMPlaceHolder" "${PODS_ROOT}/Headers/Public/Masonry" 4 | OTHER_LDFLAGS = ${PODS_DEMO_COMPLEX_CELL_MASONRY_OTHER_LDFLAGS} -ObjC 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell-Masonry/Pods-Demo-complex-cell-Masonry-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Demo_complex_cell_Masonry : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Demo_complex_cell_Masonry 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell-Masonry/Pods-Demo-complex-cell-Masonry-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-Demo-complex-cell-environment.h" 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell-Masonry/Pods-Demo-complex-cell-Masonry.xcconfig: -------------------------------------------------------------------------------- 1 | PODS_DEMO_COMPLEX_CELL_MASONRY_OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit" -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## MMPlaceHolder 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2014 ralph li 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | 29 | ## Masonry 30 | 31 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy 34 | of this software and associated documentation files (the "Software"), to deal 35 | in the Software without restriction, including without limitation the rights 36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 37 | copies of the Software, and to permit persons to whom the Software is 38 | furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in 41 | all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 49 | THE SOFTWARE. 50 | Generated by CocoaPods - http://cocoapods.org 51 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2014 ralph li 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | 39 | Title 40 | MMPlaceHolder 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 47 | 48 | Permission is hereby granted, free of charge, to any person obtaining a copy 49 | of this software and associated documentation files (the "Software"), to deal 50 | in the Software without restriction, including without limitation the rights 51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 52 | copies of the Software, and to permit persons to whom the Software is 53 | furnished to do so, subject to the following conditions: 54 | 55 | The above copyright notice and this permission notice shall be included in 56 | all copies or substantial portions of the Software. 57 | 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 64 | THE SOFTWARE. 65 | Title 66 | Masonry 67 | Type 68 | PSGroupSpecifier 69 | 70 | 71 | FooterText 72 | Generated by CocoaPods - http://cocoapods.org 73 | Title 74 | 75 | Type 76 | PSGroupSpecifier 77 | 78 | 79 | StringsTable 80 | Acknowledgements 81 | Title 82 | Acknowledgements 83 | 84 | 85 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Demo_complex_cell : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Demo_complex_cell 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell-environment.h: -------------------------------------------------------------------------------- 1 | 2 | // To check if a library is compiled with CocoaPods you 3 | // can use the `COCOAPODS` macro definition which is 4 | // defined in the xcconfigs so it is available in 5 | // headers also when they are imported in the client 6 | // project. 7 | 8 | 9 | // MMPlaceHolder 10 | #define COCOAPODS_POD_AVAILABLE_MMPlaceHolder 11 | #define COCOAPODS_VERSION_MAJOR_MMPlaceHolder 1 12 | #define COCOAPODS_VERSION_MINOR_MMPlaceHolder 8 13 | #define COCOAPODS_VERSION_PATCH_MMPlaceHolder 0 14 | 15 | // Masonry 16 | #define COCOAPODS_POD_AVAILABLE_Masonry 17 | #define COCOAPODS_VERSION_MAJOR_Masonry 0 18 | #define COCOAPODS_VERSION_MINOR_Masonry 6 19 | #define COCOAPODS_VERSION_PATCH_Masonry 1 20 | 21 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | realpath() { 12 | DIRECTORY=$(cd "${1%/*}" && pwd) 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | 61 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 62 | if [[ "${ACTION}" == "install" ]]; then 63 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 64 | fi 65 | rm -f "$RESOURCES_TO_COPY" 66 | 67 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 68 | then 69 | case "${TARGETED_DEVICE_FAMILY}" in 70 | 1,2) 71 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 72 | ;; 73 | 1) 74 | TARGET_DEVICE_ARGS="--target-device iphone" 75 | ;; 76 | 2) 77 | TARGET_DEVICE_ARGS="--target-device ipad" 78 | ;; 79 | *) 80 | TARGET_DEVICE_ARGS="--target-device mac" 81 | ;; 82 | esac 83 | 84 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 85 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 86 | while read line; do 87 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 88 | XCASSET_FILES+=("$line") 89 | fi 90 | done <<<"$OTHER_XCASSETS" 91 | 92 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 93 | fi 94 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MMPlaceHolder" "${PODS_ROOT}/Headers/Public/Masonry" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/MMPlaceHolder" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Pods-Demo-complex-cell-MMPlaceHolder" -l"Pods-Demo-complex-cell-Masonry" -framework "Foundation" -framework "UIKit" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Demo-complex-cell/Pods-Demo-complex-cell.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MMPlaceHolder" "${PODS_ROOT}/Headers/Public/Masonry" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/MMPlaceHolder" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Pods-Demo-complex-cell-MMPlaceHolder" -l"Pods-Demo-complex-cell-Masonry" -framework "Foundation" -framework "UIKit" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DemoComplexCell 2 | Demo for how to deal with complex cell 3 | 4 | 相关文章: [如何使用masonry设计复合型cell](http://adad184.com/2015/06/08/complex-cell-with-masonry/) --------------------------------------------------------------------------------