├── README.md ├── WMZTableView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── apple.xcuserdatad │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── WMZTableView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── Masonry │ ├── MASCompositeConstraint.h │ ├── MASCompositeConstraint.m │ ├── MASConstraint+Private.h │ ├── MASConstraint.h │ ├── MASConstraint.m │ ├── MASConstraintMaker.h │ ├── MASConstraintMaker.m │ ├── MASLayoutConstraint.h │ ├── MASLayoutConstraint.m │ ├── MASUtilities.h │ ├── MASViewAttribute.h │ ├── MASViewAttribute.m │ ├── MASViewConstraint.h │ ├── MASViewConstraint.m │ ├── Masonry.h │ ├── NSArray+MASAdditions.h │ ├── NSArray+MASAdditions.m │ ├── NSArray+MASShorthandAdditions.h │ ├── NSLayoutConstraint+MASDebugAdditions.h │ ├── NSLayoutConstraint+MASDebugAdditions.m │ ├── View+MASAdditions.h │ ├── View+MASAdditions.m │ ├── View+MASShorthandAdditions.h │ ├── ViewController+MASAdditions.h │ └── ViewController+MASAdditions.m ├── ViewController.h ├── ViewController.m ├── WMZTableView │ ├── WMZTableView.h │ └── WMZTableView.m ├── main.m └── source │ ├── 0.jpg │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ └── 9.jpg ├── WMZTableViewTests ├── Info.plist └── WMZTableViewTests.m └── WMZTableViewUITests ├── Info.plist └── WMZTableViewUITests.m /README.md: -------------------------------------------------------------------------------- 1 | # WMZTableView 2 | //简单的封装tableview通过链式调用 3 | GroupTableView() 4 | .wAutoCell(YES) 5 | .wMasonryConfig(self.view, ^(MASConstraintMaker *make) { 6 | make.edges.mas_equalTo(0); 7 | }, self.modelArr) 8 | 9 | 1 支持自定义自己写cell 10 | 2 支持通过model控制cell不需要import cell类 ,直接插入指定的model即可 不需要写cell的实现方法 11 | 3 支持局部刷新 12 | -------------------------------------------------------------------------------- /WMZTableView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 185EACD6217D9E1900C6B792 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 185EACD5217D9E1900C6B792 /* AppDelegate.m */; }; 11 | 185EACD9217D9E1900C6B792 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 185EACD8217D9E1900C6B792 /* ViewController.m */; }; 12 | 185EACDC217D9E1900C6B792 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 185EACDA217D9E1900C6B792 /* Main.storyboard */; }; 13 | 185EACDE217D9E1C00C6B792 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 185EACDD217D9E1C00C6B792 /* Assets.xcassets */; }; 14 | 185EACE1217D9E1C00C6B792 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 185EACDF217D9E1C00C6B792 /* LaunchScreen.storyboard */; }; 15 | 185EACE4217D9E1C00C6B792 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 185EACE3217D9E1C00C6B792 /* main.m */; }; 16 | 185EACEE217D9E1C00C6B792 /* WMZTableViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 185EACED217D9E1C00C6B792 /* WMZTableViewTests.m */; }; 17 | 185EACF9217D9E1C00C6B792 /* WMZTableViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 185EACF8217D9E1C00C6B792 /* WMZTableViewUITests.m */; }; 18 | 185EAD09217DA23400C6B792 /* WMZTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 185EAD08217DA23400C6B792 /* WMZTableView.m */; }; 19 | 1891BD8421806E6600159EF2 /* MASCompositeConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD6C21806E6600159EF2 /* MASCompositeConstraint.m */; }; 20 | 1891BD8521806E6600159EF2 /* MASConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD6F21806E6600159EF2 /* MASConstraint.m */; }; 21 | 1891BD8621806E6600159EF2 /* MASConstraintMaker.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD7121806E6600159EF2 /* MASConstraintMaker.m */; }; 22 | 1891BD8721806E6600159EF2 /* MASLayoutConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD7321806E6600159EF2 /* MASLayoutConstraint.m */; }; 23 | 1891BD8821806E6600159EF2 /* MASViewAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD7721806E6600159EF2 /* MASViewAttribute.m */; }; 24 | 1891BD8921806E6600159EF2 /* MASViewConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD7921806E6600159EF2 /* MASViewConstraint.m */; }; 25 | 1891BD8A21806E6600159EF2 /* NSArray+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD7B21806E6600159EF2 /* NSArray+MASAdditions.m */; }; 26 | 1891BD8B21806E6600159EF2 /* NSLayoutConstraint+MASDebugAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD7E21806E6600159EF2 /* NSLayoutConstraint+MASDebugAdditions.m */; }; 27 | 1891BD8C21806E6600159EF2 /* View+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD8021806E6600159EF2 /* View+MASAdditions.m */; }; 28 | 1891BD8D21806E6600159EF2 /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1891BD8321806E6600159EF2 /* ViewController+MASAdditions.m */; }; 29 | 18A2509C224B6B6F00B5C6B8 /* 0.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A25092224B6B6F00B5C6B8 /* 0.jpg */; }; 30 | 18A2509D224B6B6F00B5C6B8 /* 1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A25093224B6B6F00B5C6B8 /* 1.jpg */; }; 31 | 18A2509E224B6B6F00B5C6B8 /* 2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A25094224B6B6F00B5C6B8 /* 2.jpg */; }; 32 | 18A2509F224B6B6F00B5C6B8 /* 3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A25095224B6B6F00B5C6B8 /* 3.jpg */; }; 33 | 18A250A0224B6B6F00B5C6B8 /* 4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A25096224B6B6F00B5C6B8 /* 4.jpg */; }; 34 | 18A250A1224B6B6F00B5C6B8 /* 5.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A25097224B6B6F00B5C6B8 /* 5.jpg */; }; 35 | 18A250A2224B6B6F00B5C6B8 /* 6.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A25098224B6B6F00B5C6B8 /* 6.jpg */; }; 36 | 18A250A3224B6B6F00B5C6B8 /* 7.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A25099224B6B6F00B5C6B8 /* 7.jpg */; }; 37 | 18A250A4224B6B6F00B5C6B8 /* 8.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A2509A224B6B6F00B5C6B8 /* 8.jpg */; }; 38 | 18A250A5224B6B6F00B5C6B8 /* 9.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18A2509B224B6B6F00B5C6B8 /* 9.jpg */; }; 39 | /* End PBXBuildFile section */ 40 | 41 | /* Begin PBXContainerItemProxy section */ 42 | 185EACEA217D9E1C00C6B792 /* PBXContainerItemProxy */ = { 43 | isa = PBXContainerItemProxy; 44 | containerPortal = 185EACC9217D9E1900C6B792 /* Project object */; 45 | proxyType = 1; 46 | remoteGlobalIDString = 185EACD0217D9E1900C6B792; 47 | remoteInfo = WMZTableView; 48 | }; 49 | 185EACF5217D9E1C00C6B792 /* PBXContainerItemProxy */ = { 50 | isa = PBXContainerItemProxy; 51 | containerPortal = 185EACC9217D9E1900C6B792 /* Project object */; 52 | proxyType = 1; 53 | remoteGlobalIDString = 185EACD0217D9E1900C6B792; 54 | remoteInfo = WMZTableView; 55 | }; 56 | /* End PBXContainerItemProxy section */ 57 | 58 | /* Begin PBXFileReference section */ 59 | 185EACD1217D9E1900C6B792 /* WMZTableView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WMZTableView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | 185EACD4217D9E1900C6B792 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 61 | 185EACD5217D9E1900C6B792 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 62 | 185EACD7217D9E1900C6B792 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 63 | 185EACD8217D9E1900C6B792 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 64 | 185EACDB217D9E1900C6B792 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 65 | 185EACDD217D9E1C00C6B792 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 66 | 185EACE0217D9E1C00C6B792 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 67 | 185EACE2217D9E1C00C6B792 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 68 | 185EACE3217D9E1C00C6B792 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 69 | 185EACE9217D9E1C00C6B792 /* WMZTableViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WMZTableViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 70 | 185EACED217D9E1C00C6B792 /* WMZTableViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WMZTableViewTests.m; sourceTree = ""; }; 71 | 185EACEF217D9E1C00C6B792 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 72 | 185EACF4217D9E1C00C6B792 /* WMZTableViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WMZTableViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 73 | 185EACF8217D9E1C00C6B792 /* WMZTableViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WMZTableViewUITests.m; sourceTree = ""; }; 74 | 185EACFA217D9E1C00C6B792 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 75 | 185EAD07217DA23400C6B792 /* WMZTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WMZTableView.h; sourceTree = ""; }; 76 | 185EAD08217DA23400C6B792 /* WMZTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WMZTableView.m; sourceTree = ""; }; 77 | 1891BD6B21806E6600159EF2 /* MASCompositeConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASCompositeConstraint.h; sourceTree = ""; }; 78 | 1891BD6C21806E6600159EF2 /* MASCompositeConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASCompositeConstraint.m; sourceTree = ""; }; 79 | 1891BD6D21806E6600159EF2 /* MASConstraint+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASConstraint+Private.h"; sourceTree = ""; }; 80 | 1891BD6E21806E6600159EF2 /* MASConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraint.h; sourceTree = ""; }; 81 | 1891BD6F21806E6600159EF2 /* MASConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraint.m; sourceTree = ""; }; 82 | 1891BD7021806E6600159EF2 /* MASConstraintMaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraintMaker.h; sourceTree = ""; }; 83 | 1891BD7121806E6600159EF2 /* MASConstraintMaker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraintMaker.m; sourceTree = ""; }; 84 | 1891BD7221806E6600159EF2 /* MASLayoutConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASLayoutConstraint.h; sourceTree = ""; }; 85 | 1891BD7321806E6600159EF2 /* MASLayoutConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASLayoutConstraint.m; sourceTree = ""; }; 86 | 1891BD7421806E6600159EF2 /* Masonry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Masonry.h; sourceTree = ""; }; 87 | 1891BD7521806E6600159EF2 /* MASUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASUtilities.h; sourceTree = ""; }; 88 | 1891BD7621806E6600159EF2 /* MASViewAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewAttribute.h; sourceTree = ""; }; 89 | 1891BD7721806E6600159EF2 /* MASViewAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewAttribute.m; sourceTree = ""; }; 90 | 1891BD7821806E6600159EF2 /* MASViewConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewConstraint.h; sourceTree = ""; }; 91 | 1891BD7921806E6600159EF2 /* MASViewConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewConstraint.m; sourceTree = ""; }; 92 | 1891BD7A21806E6600159EF2 /* NSArray+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASAdditions.h"; sourceTree = ""; }; 93 | 1891BD7B21806E6600159EF2 /* NSArray+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+MASAdditions.m"; sourceTree = ""; }; 94 | 1891BD7C21806E6600159EF2 /* NSArray+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASShorthandAdditions.h"; sourceTree = ""; }; 95 | 1891BD7D21806E6600159EF2 /* NSLayoutConstraint+MASDebugAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSLayoutConstraint+MASDebugAdditions.h"; sourceTree = ""; }; 96 | 1891BD7E21806E6600159EF2 /* NSLayoutConstraint+MASDebugAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+MASDebugAdditions.m"; sourceTree = ""; }; 97 | 1891BD7F21806E6600159EF2 /* View+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASAdditions.h"; sourceTree = ""; }; 98 | 1891BD8021806E6600159EF2 /* View+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "View+MASAdditions.m"; sourceTree = ""; }; 99 | 1891BD8121806E6600159EF2 /* View+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASShorthandAdditions.h"; sourceTree = ""; }; 100 | 1891BD8221806E6600159EF2 /* ViewController+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ViewController+MASAdditions.h"; sourceTree = ""; }; 101 | 1891BD8321806E6600159EF2 /* ViewController+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ViewController+MASAdditions.m"; sourceTree = ""; }; 102 | 18A25092224B6B6F00B5C6B8 /* 0.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 0.jpg; sourceTree = ""; }; 103 | 18A25093224B6B6F00B5C6B8 /* 1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpg; sourceTree = ""; }; 104 | 18A25094224B6B6F00B5C6B8 /* 2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 2.jpg; sourceTree = ""; }; 105 | 18A25095224B6B6F00B5C6B8 /* 3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 3.jpg; sourceTree = ""; }; 106 | 18A25096224B6B6F00B5C6B8 /* 4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 4.jpg; sourceTree = ""; }; 107 | 18A25097224B6B6F00B5C6B8 /* 5.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 5.jpg; sourceTree = ""; }; 108 | 18A25098224B6B6F00B5C6B8 /* 6.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 6.jpg; sourceTree = ""; }; 109 | 18A25099224B6B6F00B5C6B8 /* 7.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 7.jpg; sourceTree = ""; }; 110 | 18A2509A224B6B6F00B5C6B8 /* 8.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 8.jpg; sourceTree = ""; }; 111 | 18A2509B224B6B6F00B5C6B8 /* 9.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 9.jpg; sourceTree = ""; }; 112 | /* End PBXFileReference section */ 113 | 114 | /* Begin PBXFrameworksBuildPhase section */ 115 | 185EACCE217D9E1900C6B792 /* Frameworks */ = { 116 | isa = PBXFrameworksBuildPhase; 117 | buildActionMask = 2147483647; 118 | files = ( 119 | ); 120 | runOnlyForDeploymentPostprocessing = 0; 121 | }; 122 | 185EACE6217D9E1C00C6B792 /* Frameworks */ = { 123 | isa = PBXFrameworksBuildPhase; 124 | buildActionMask = 2147483647; 125 | files = ( 126 | ); 127 | runOnlyForDeploymentPostprocessing = 0; 128 | }; 129 | 185EACF1217D9E1C00C6B792 /* Frameworks */ = { 130 | isa = PBXFrameworksBuildPhase; 131 | buildActionMask = 2147483647; 132 | files = ( 133 | ); 134 | runOnlyForDeploymentPostprocessing = 0; 135 | }; 136 | /* End PBXFrameworksBuildPhase section */ 137 | 138 | /* Begin PBXGroup section */ 139 | 185EACC8217D9E1900C6B792 = { 140 | isa = PBXGroup; 141 | children = ( 142 | 185EACD3217D9E1900C6B792 /* WMZTableView */, 143 | 185EACEC217D9E1C00C6B792 /* WMZTableViewTests */, 144 | 185EACF7217D9E1C00C6B792 /* WMZTableViewUITests */, 145 | 185EACD2217D9E1900C6B792 /* Products */, 146 | ); 147 | sourceTree = ""; 148 | }; 149 | 185EACD2217D9E1900C6B792 /* Products */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | 185EACD1217D9E1900C6B792 /* WMZTableView.app */, 153 | 185EACE9217D9E1C00C6B792 /* WMZTableViewTests.xctest */, 154 | 185EACF4217D9E1C00C6B792 /* WMZTableViewUITests.xctest */, 155 | ); 156 | name = Products; 157 | sourceTree = ""; 158 | }; 159 | 185EACD3217D9E1900C6B792 /* WMZTableView */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | 18A25091224B6B6F00B5C6B8 /* source */, 163 | 1891BD6A21806E6600159EF2 /* Masonry */, 164 | 185EAD06217DA1FE00C6B792 /* WMZTableView */, 165 | 185EACD4217D9E1900C6B792 /* AppDelegate.h */, 166 | 185EACD5217D9E1900C6B792 /* AppDelegate.m */, 167 | 185EACD7217D9E1900C6B792 /* ViewController.h */, 168 | 185EACD8217D9E1900C6B792 /* ViewController.m */, 169 | 185EACDA217D9E1900C6B792 /* Main.storyboard */, 170 | 185EACDD217D9E1C00C6B792 /* Assets.xcassets */, 171 | 185EACDF217D9E1C00C6B792 /* LaunchScreen.storyboard */, 172 | 185EACE2217D9E1C00C6B792 /* Info.plist */, 173 | 185EACE3217D9E1C00C6B792 /* main.m */, 174 | ); 175 | path = WMZTableView; 176 | sourceTree = ""; 177 | }; 178 | 185EACEC217D9E1C00C6B792 /* WMZTableViewTests */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | 185EACED217D9E1C00C6B792 /* WMZTableViewTests.m */, 182 | 185EACEF217D9E1C00C6B792 /* Info.plist */, 183 | ); 184 | path = WMZTableViewTests; 185 | sourceTree = ""; 186 | }; 187 | 185EACF7217D9E1C00C6B792 /* WMZTableViewUITests */ = { 188 | isa = PBXGroup; 189 | children = ( 190 | 185EACF8217D9E1C00C6B792 /* WMZTableViewUITests.m */, 191 | 185EACFA217D9E1C00C6B792 /* Info.plist */, 192 | ); 193 | path = WMZTableViewUITests; 194 | sourceTree = ""; 195 | }; 196 | 185EAD06217DA1FE00C6B792 /* WMZTableView */ = { 197 | isa = PBXGroup; 198 | children = ( 199 | 185EAD07217DA23400C6B792 /* WMZTableView.h */, 200 | 185EAD08217DA23400C6B792 /* WMZTableView.m */, 201 | ); 202 | path = WMZTableView; 203 | sourceTree = ""; 204 | }; 205 | 1891BD6A21806E6600159EF2 /* Masonry */ = { 206 | isa = PBXGroup; 207 | children = ( 208 | 1891BD6B21806E6600159EF2 /* MASCompositeConstraint.h */, 209 | 1891BD6C21806E6600159EF2 /* MASCompositeConstraint.m */, 210 | 1891BD6D21806E6600159EF2 /* MASConstraint+Private.h */, 211 | 1891BD6E21806E6600159EF2 /* MASConstraint.h */, 212 | 1891BD6F21806E6600159EF2 /* MASConstraint.m */, 213 | 1891BD7021806E6600159EF2 /* MASConstraintMaker.h */, 214 | 1891BD7121806E6600159EF2 /* MASConstraintMaker.m */, 215 | 1891BD7221806E6600159EF2 /* MASLayoutConstraint.h */, 216 | 1891BD7321806E6600159EF2 /* MASLayoutConstraint.m */, 217 | 1891BD7421806E6600159EF2 /* Masonry.h */, 218 | 1891BD7521806E6600159EF2 /* MASUtilities.h */, 219 | 1891BD7621806E6600159EF2 /* MASViewAttribute.h */, 220 | 1891BD7721806E6600159EF2 /* MASViewAttribute.m */, 221 | 1891BD7821806E6600159EF2 /* MASViewConstraint.h */, 222 | 1891BD7921806E6600159EF2 /* MASViewConstraint.m */, 223 | 1891BD7A21806E6600159EF2 /* NSArray+MASAdditions.h */, 224 | 1891BD7B21806E6600159EF2 /* NSArray+MASAdditions.m */, 225 | 1891BD7C21806E6600159EF2 /* NSArray+MASShorthandAdditions.h */, 226 | 1891BD7D21806E6600159EF2 /* NSLayoutConstraint+MASDebugAdditions.h */, 227 | 1891BD7E21806E6600159EF2 /* NSLayoutConstraint+MASDebugAdditions.m */, 228 | 1891BD7F21806E6600159EF2 /* View+MASAdditions.h */, 229 | 1891BD8021806E6600159EF2 /* View+MASAdditions.m */, 230 | 1891BD8121806E6600159EF2 /* View+MASShorthandAdditions.h */, 231 | 1891BD8221806E6600159EF2 /* ViewController+MASAdditions.h */, 232 | 1891BD8321806E6600159EF2 /* ViewController+MASAdditions.m */, 233 | ); 234 | path = Masonry; 235 | sourceTree = ""; 236 | }; 237 | 18A25091224B6B6F00B5C6B8 /* source */ = { 238 | isa = PBXGroup; 239 | children = ( 240 | 18A25092224B6B6F00B5C6B8 /* 0.jpg */, 241 | 18A25093224B6B6F00B5C6B8 /* 1.jpg */, 242 | 18A25094224B6B6F00B5C6B8 /* 2.jpg */, 243 | 18A25095224B6B6F00B5C6B8 /* 3.jpg */, 244 | 18A25096224B6B6F00B5C6B8 /* 4.jpg */, 245 | 18A25097224B6B6F00B5C6B8 /* 5.jpg */, 246 | 18A25098224B6B6F00B5C6B8 /* 6.jpg */, 247 | 18A25099224B6B6F00B5C6B8 /* 7.jpg */, 248 | 18A2509A224B6B6F00B5C6B8 /* 8.jpg */, 249 | 18A2509B224B6B6F00B5C6B8 /* 9.jpg */, 250 | ); 251 | path = source; 252 | sourceTree = ""; 253 | }; 254 | /* End PBXGroup section */ 255 | 256 | /* Begin PBXNativeTarget section */ 257 | 185EACD0217D9E1900C6B792 /* WMZTableView */ = { 258 | isa = PBXNativeTarget; 259 | buildConfigurationList = 185EACFD217D9E1C00C6B792 /* Build configuration list for PBXNativeTarget "WMZTableView" */; 260 | buildPhases = ( 261 | 185EACCD217D9E1900C6B792 /* Sources */, 262 | 185EACCE217D9E1900C6B792 /* Frameworks */, 263 | 185EACCF217D9E1900C6B792 /* Resources */, 264 | ); 265 | buildRules = ( 266 | ); 267 | dependencies = ( 268 | ); 269 | name = WMZTableView; 270 | productName = WMZTableView; 271 | productReference = 185EACD1217D9E1900C6B792 /* WMZTableView.app */; 272 | productType = "com.apple.product-type.application"; 273 | }; 274 | 185EACE8217D9E1C00C6B792 /* WMZTableViewTests */ = { 275 | isa = PBXNativeTarget; 276 | buildConfigurationList = 185EAD00217D9E1C00C6B792 /* Build configuration list for PBXNativeTarget "WMZTableViewTests" */; 277 | buildPhases = ( 278 | 185EACE5217D9E1C00C6B792 /* Sources */, 279 | 185EACE6217D9E1C00C6B792 /* Frameworks */, 280 | 185EACE7217D9E1C00C6B792 /* Resources */, 281 | ); 282 | buildRules = ( 283 | ); 284 | dependencies = ( 285 | 185EACEB217D9E1C00C6B792 /* PBXTargetDependency */, 286 | ); 287 | name = WMZTableViewTests; 288 | productName = WMZTableViewTests; 289 | productReference = 185EACE9217D9E1C00C6B792 /* WMZTableViewTests.xctest */; 290 | productType = "com.apple.product-type.bundle.unit-test"; 291 | }; 292 | 185EACF3217D9E1C00C6B792 /* WMZTableViewUITests */ = { 293 | isa = PBXNativeTarget; 294 | buildConfigurationList = 185EAD03217D9E1C00C6B792 /* Build configuration list for PBXNativeTarget "WMZTableViewUITests" */; 295 | buildPhases = ( 296 | 185EACF0217D9E1C00C6B792 /* Sources */, 297 | 185EACF1217D9E1C00C6B792 /* Frameworks */, 298 | 185EACF2217D9E1C00C6B792 /* Resources */, 299 | ); 300 | buildRules = ( 301 | ); 302 | dependencies = ( 303 | 185EACF6217D9E1C00C6B792 /* PBXTargetDependency */, 304 | ); 305 | name = WMZTableViewUITests; 306 | productName = WMZTableViewUITests; 307 | productReference = 185EACF4217D9E1C00C6B792 /* WMZTableViewUITests.xctest */; 308 | productType = "com.apple.product-type.bundle.ui-testing"; 309 | }; 310 | /* End PBXNativeTarget section */ 311 | 312 | /* Begin PBXProject section */ 313 | 185EACC9217D9E1900C6B792 /* Project object */ = { 314 | isa = PBXProject; 315 | attributes = { 316 | LastUpgradeCheck = 1000; 317 | ORGANIZATIONNAME = wmz; 318 | TargetAttributes = { 319 | 185EACD0217D9E1900C6B792 = { 320 | CreatedOnToolsVersion = 10.0; 321 | }; 322 | 185EACE8217D9E1C00C6B792 = { 323 | CreatedOnToolsVersion = 10.0; 324 | TestTargetID = 185EACD0217D9E1900C6B792; 325 | }; 326 | 185EACF3217D9E1C00C6B792 = { 327 | CreatedOnToolsVersion = 10.0; 328 | TestTargetID = 185EACD0217D9E1900C6B792; 329 | }; 330 | }; 331 | }; 332 | buildConfigurationList = 185EACCC217D9E1900C6B792 /* Build configuration list for PBXProject "WMZTableView" */; 333 | compatibilityVersion = "Xcode 9.3"; 334 | developmentRegion = en; 335 | hasScannedForEncodings = 0; 336 | knownRegions = ( 337 | en, 338 | Base, 339 | ); 340 | mainGroup = 185EACC8217D9E1900C6B792; 341 | productRefGroup = 185EACD2217D9E1900C6B792 /* Products */; 342 | projectDirPath = ""; 343 | projectRoot = ""; 344 | targets = ( 345 | 185EACD0217D9E1900C6B792 /* WMZTableView */, 346 | 185EACE8217D9E1C00C6B792 /* WMZTableViewTests */, 347 | 185EACF3217D9E1C00C6B792 /* WMZTableViewUITests */, 348 | ); 349 | }; 350 | /* End PBXProject section */ 351 | 352 | /* Begin PBXResourcesBuildPhase section */ 353 | 185EACCF217D9E1900C6B792 /* Resources */ = { 354 | isa = PBXResourcesBuildPhase; 355 | buildActionMask = 2147483647; 356 | files = ( 357 | 18A250A5224B6B6F00B5C6B8 /* 9.jpg in Resources */, 358 | 18A250A4224B6B6F00B5C6B8 /* 8.jpg in Resources */, 359 | 18A250A3224B6B6F00B5C6B8 /* 7.jpg in Resources */, 360 | 18A250A0224B6B6F00B5C6B8 /* 4.jpg in Resources */, 361 | 18A2509E224B6B6F00B5C6B8 /* 2.jpg in Resources */, 362 | 18A2509C224B6B6F00B5C6B8 /* 0.jpg in Resources */, 363 | 18A250A1224B6B6F00B5C6B8 /* 5.jpg in Resources */, 364 | 18A250A2224B6B6F00B5C6B8 /* 6.jpg in Resources */, 365 | 185EACE1217D9E1C00C6B792 /* LaunchScreen.storyboard in Resources */, 366 | 185EACDE217D9E1C00C6B792 /* Assets.xcassets in Resources */, 367 | 185EACDC217D9E1900C6B792 /* Main.storyboard in Resources */, 368 | 18A2509F224B6B6F00B5C6B8 /* 3.jpg in Resources */, 369 | 18A2509D224B6B6F00B5C6B8 /* 1.jpg in Resources */, 370 | ); 371 | runOnlyForDeploymentPostprocessing = 0; 372 | }; 373 | 185EACE7217D9E1C00C6B792 /* Resources */ = { 374 | isa = PBXResourcesBuildPhase; 375 | buildActionMask = 2147483647; 376 | files = ( 377 | ); 378 | runOnlyForDeploymentPostprocessing = 0; 379 | }; 380 | 185EACF2217D9E1C00C6B792 /* Resources */ = { 381 | isa = PBXResourcesBuildPhase; 382 | buildActionMask = 2147483647; 383 | files = ( 384 | ); 385 | runOnlyForDeploymentPostprocessing = 0; 386 | }; 387 | /* End PBXResourcesBuildPhase section */ 388 | 389 | /* Begin PBXSourcesBuildPhase section */ 390 | 185EACCD217D9E1900C6B792 /* Sources */ = { 391 | isa = PBXSourcesBuildPhase; 392 | buildActionMask = 2147483647; 393 | files = ( 394 | 1891BD8621806E6600159EF2 /* MASConstraintMaker.m in Sources */, 395 | 185EACD9217D9E1900C6B792 /* ViewController.m in Sources */, 396 | 185EACE4217D9E1C00C6B792 /* main.m in Sources */, 397 | 1891BD8521806E6600159EF2 /* MASConstraint.m in Sources */, 398 | 1891BD8D21806E6600159EF2 /* ViewController+MASAdditions.m in Sources */, 399 | 1891BD8721806E6600159EF2 /* MASLayoutConstraint.m in Sources */, 400 | 1891BD8A21806E6600159EF2 /* NSArray+MASAdditions.m in Sources */, 401 | 1891BD8921806E6600159EF2 /* MASViewConstraint.m in Sources */, 402 | 1891BD8821806E6600159EF2 /* MASViewAttribute.m in Sources */, 403 | 1891BD8C21806E6600159EF2 /* View+MASAdditions.m in Sources */, 404 | 185EAD09217DA23400C6B792 /* WMZTableView.m in Sources */, 405 | 185EACD6217D9E1900C6B792 /* AppDelegate.m in Sources */, 406 | 1891BD8421806E6600159EF2 /* MASCompositeConstraint.m in Sources */, 407 | 1891BD8B21806E6600159EF2 /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, 408 | ); 409 | runOnlyForDeploymentPostprocessing = 0; 410 | }; 411 | 185EACE5217D9E1C00C6B792 /* Sources */ = { 412 | isa = PBXSourcesBuildPhase; 413 | buildActionMask = 2147483647; 414 | files = ( 415 | 185EACEE217D9E1C00C6B792 /* WMZTableViewTests.m in Sources */, 416 | ); 417 | runOnlyForDeploymentPostprocessing = 0; 418 | }; 419 | 185EACF0217D9E1C00C6B792 /* Sources */ = { 420 | isa = PBXSourcesBuildPhase; 421 | buildActionMask = 2147483647; 422 | files = ( 423 | 185EACF9217D9E1C00C6B792 /* WMZTableViewUITests.m in Sources */, 424 | ); 425 | runOnlyForDeploymentPostprocessing = 0; 426 | }; 427 | /* End PBXSourcesBuildPhase section */ 428 | 429 | /* Begin PBXTargetDependency section */ 430 | 185EACEB217D9E1C00C6B792 /* PBXTargetDependency */ = { 431 | isa = PBXTargetDependency; 432 | target = 185EACD0217D9E1900C6B792 /* WMZTableView */; 433 | targetProxy = 185EACEA217D9E1C00C6B792 /* PBXContainerItemProxy */; 434 | }; 435 | 185EACF6217D9E1C00C6B792 /* PBXTargetDependency */ = { 436 | isa = PBXTargetDependency; 437 | target = 185EACD0217D9E1900C6B792 /* WMZTableView */; 438 | targetProxy = 185EACF5217D9E1C00C6B792 /* PBXContainerItemProxy */; 439 | }; 440 | /* End PBXTargetDependency section */ 441 | 442 | /* Begin PBXVariantGroup section */ 443 | 185EACDA217D9E1900C6B792 /* Main.storyboard */ = { 444 | isa = PBXVariantGroup; 445 | children = ( 446 | 185EACDB217D9E1900C6B792 /* Base */, 447 | ); 448 | name = Main.storyboard; 449 | sourceTree = ""; 450 | }; 451 | 185EACDF217D9E1C00C6B792 /* LaunchScreen.storyboard */ = { 452 | isa = PBXVariantGroup; 453 | children = ( 454 | 185EACE0217D9E1C00C6B792 /* Base */, 455 | ); 456 | name = LaunchScreen.storyboard; 457 | sourceTree = ""; 458 | }; 459 | /* End PBXVariantGroup section */ 460 | 461 | /* Begin XCBuildConfiguration section */ 462 | 185EACFB217D9E1C00C6B792 /* Debug */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | ALWAYS_SEARCH_USER_PATHS = NO; 466 | CLANG_ANALYZER_NONNULL = YES; 467 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 468 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 469 | CLANG_CXX_LIBRARY = "libc++"; 470 | CLANG_ENABLE_MODULES = YES; 471 | CLANG_ENABLE_OBJC_ARC = YES; 472 | CLANG_ENABLE_OBJC_WEAK = YES; 473 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 474 | CLANG_WARN_BOOL_CONVERSION = YES; 475 | CLANG_WARN_COMMA = YES; 476 | CLANG_WARN_CONSTANT_CONVERSION = YES; 477 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 478 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 479 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 480 | CLANG_WARN_EMPTY_BODY = YES; 481 | CLANG_WARN_ENUM_CONVERSION = YES; 482 | CLANG_WARN_INFINITE_RECURSION = YES; 483 | CLANG_WARN_INT_CONVERSION = YES; 484 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 485 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 486 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 487 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 488 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 489 | CLANG_WARN_STRICT_PROTOTYPES = YES; 490 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 491 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 492 | CLANG_WARN_UNREACHABLE_CODE = YES; 493 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 494 | CODE_SIGN_IDENTITY = "iPhone Developer"; 495 | COPY_PHASE_STRIP = NO; 496 | DEBUG_INFORMATION_FORMAT = dwarf; 497 | ENABLE_STRICT_OBJC_MSGSEND = YES; 498 | ENABLE_TESTABILITY = YES; 499 | GCC_C_LANGUAGE_STANDARD = gnu11; 500 | GCC_DYNAMIC_NO_PIC = NO; 501 | GCC_NO_COMMON_BLOCKS = YES; 502 | GCC_OPTIMIZATION_LEVEL = 0; 503 | GCC_PREPROCESSOR_DEFINITIONS = ( 504 | "DEBUG=1", 505 | "$(inherited)", 506 | ); 507 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 508 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 509 | GCC_WARN_UNDECLARED_SELECTOR = YES; 510 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 511 | GCC_WARN_UNUSED_FUNCTION = YES; 512 | GCC_WARN_UNUSED_VARIABLE = YES; 513 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 514 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 515 | MTL_FAST_MATH = YES; 516 | ONLY_ACTIVE_ARCH = YES; 517 | SDKROOT = iphoneos; 518 | }; 519 | name = Debug; 520 | }; 521 | 185EACFC217D9E1C00C6B792 /* Release */ = { 522 | isa = XCBuildConfiguration; 523 | buildSettings = { 524 | ALWAYS_SEARCH_USER_PATHS = NO; 525 | CLANG_ANALYZER_NONNULL = YES; 526 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 527 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 528 | CLANG_CXX_LIBRARY = "libc++"; 529 | CLANG_ENABLE_MODULES = YES; 530 | CLANG_ENABLE_OBJC_ARC = YES; 531 | CLANG_ENABLE_OBJC_WEAK = YES; 532 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 533 | CLANG_WARN_BOOL_CONVERSION = YES; 534 | CLANG_WARN_COMMA = YES; 535 | CLANG_WARN_CONSTANT_CONVERSION = YES; 536 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 537 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 538 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 539 | CLANG_WARN_EMPTY_BODY = YES; 540 | CLANG_WARN_ENUM_CONVERSION = YES; 541 | CLANG_WARN_INFINITE_RECURSION = YES; 542 | CLANG_WARN_INT_CONVERSION = YES; 543 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 544 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 545 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 546 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 547 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 548 | CLANG_WARN_STRICT_PROTOTYPES = YES; 549 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 550 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 551 | CLANG_WARN_UNREACHABLE_CODE = YES; 552 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 553 | CODE_SIGN_IDENTITY = "iPhone Developer"; 554 | COPY_PHASE_STRIP = NO; 555 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 556 | ENABLE_NS_ASSERTIONS = NO; 557 | ENABLE_STRICT_OBJC_MSGSEND = YES; 558 | GCC_C_LANGUAGE_STANDARD = gnu11; 559 | GCC_NO_COMMON_BLOCKS = YES; 560 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 561 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 562 | GCC_WARN_UNDECLARED_SELECTOR = YES; 563 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 564 | GCC_WARN_UNUSED_FUNCTION = YES; 565 | GCC_WARN_UNUSED_VARIABLE = YES; 566 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 567 | MTL_ENABLE_DEBUG_INFO = NO; 568 | MTL_FAST_MATH = YES; 569 | SDKROOT = iphoneos; 570 | VALIDATE_PRODUCT = YES; 571 | }; 572 | name = Release; 573 | }; 574 | 185EACFE217D9E1C00C6B792 /* Debug */ = { 575 | isa = XCBuildConfiguration; 576 | buildSettings = { 577 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 578 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = NO; 579 | CODE_SIGN_IDENTITY = "iPhone Developer"; 580 | CODE_SIGN_STYLE = Automatic; 581 | DEVELOPMENT_TEAM = HR6T4LQD9T; 582 | INFOPLIST_FILE = WMZTableView/Info.plist; 583 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 584 | LD_RUNPATH_SEARCH_PATHS = ( 585 | "$(inherited)", 586 | "@executable_path/Frameworks", 587 | ); 588 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZTableView; 589 | PRODUCT_NAME = "$(TARGET_NAME)"; 590 | PROVISIONING_PROFILE_SPECIFIER = ""; 591 | TARGETED_DEVICE_FAMILY = "1,2"; 592 | }; 593 | name = Debug; 594 | }; 595 | 185EACFF217D9E1C00C6B792 /* Release */ = { 596 | isa = XCBuildConfiguration; 597 | buildSettings = { 598 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 599 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = NO; 600 | CODE_SIGN_IDENTITY = "iPhone Developer"; 601 | CODE_SIGN_STYLE = Automatic; 602 | DEVELOPMENT_TEAM = HR6T4LQD9T; 603 | INFOPLIST_FILE = WMZTableView/Info.plist; 604 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 605 | LD_RUNPATH_SEARCH_PATHS = ( 606 | "$(inherited)", 607 | "@executable_path/Frameworks", 608 | ); 609 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZTableView; 610 | PRODUCT_NAME = "$(TARGET_NAME)"; 611 | PROVISIONING_PROFILE_SPECIFIER = ""; 612 | TARGETED_DEVICE_FAMILY = "1,2"; 613 | }; 614 | name = Release; 615 | }; 616 | 185EAD01217D9E1C00C6B792 /* Debug */ = { 617 | isa = XCBuildConfiguration; 618 | buildSettings = { 619 | BUNDLE_LOADER = "$(TEST_HOST)"; 620 | CODE_SIGN_STYLE = Automatic; 621 | DEVELOPMENT_TEAM = HR6T4LQD9T; 622 | INFOPLIST_FILE = WMZTableViewTests/Info.plist; 623 | LD_RUNPATH_SEARCH_PATHS = ( 624 | "$(inherited)", 625 | "@executable_path/Frameworks", 626 | "@loader_path/Frameworks", 627 | ); 628 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZTableViewTests; 629 | PRODUCT_NAME = "$(TARGET_NAME)"; 630 | TARGETED_DEVICE_FAMILY = "1,2"; 631 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WMZTableView.app/WMZTableView"; 632 | }; 633 | name = Debug; 634 | }; 635 | 185EAD02217D9E1C00C6B792 /* Release */ = { 636 | isa = XCBuildConfiguration; 637 | buildSettings = { 638 | BUNDLE_LOADER = "$(TEST_HOST)"; 639 | CODE_SIGN_STYLE = Automatic; 640 | DEVELOPMENT_TEAM = HR6T4LQD9T; 641 | INFOPLIST_FILE = WMZTableViewTests/Info.plist; 642 | LD_RUNPATH_SEARCH_PATHS = ( 643 | "$(inherited)", 644 | "@executable_path/Frameworks", 645 | "@loader_path/Frameworks", 646 | ); 647 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZTableViewTests; 648 | PRODUCT_NAME = "$(TARGET_NAME)"; 649 | TARGETED_DEVICE_FAMILY = "1,2"; 650 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WMZTableView.app/WMZTableView"; 651 | }; 652 | name = Release; 653 | }; 654 | 185EAD04217D9E1C00C6B792 /* Debug */ = { 655 | isa = XCBuildConfiguration; 656 | buildSettings = { 657 | CODE_SIGN_STYLE = Automatic; 658 | DEVELOPMENT_TEAM = HR6T4LQD9T; 659 | INFOPLIST_FILE = WMZTableViewUITests/Info.plist; 660 | LD_RUNPATH_SEARCH_PATHS = ( 661 | "$(inherited)", 662 | "@executable_path/Frameworks", 663 | "@loader_path/Frameworks", 664 | ); 665 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZTableViewUITests; 666 | PRODUCT_NAME = "$(TARGET_NAME)"; 667 | TARGETED_DEVICE_FAMILY = "1,2"; 668 | TEST_TARGET_NAME = WMZTableView; 669 | }; 670 | name = Debug; 671 | }; 672 | 185EAD05217D9E1C00C6B792 /* Release */ = { 673 | isa = XCBuildConfiguration; 674 | buildSettings = { 675 | CODE_SIGN_STYLE = Automatic; 676 | DEVELOPMENT_TEAM = HR6T4LQD9T; 677 | INFOPLIST_FILE = WMZTableViewUITests/Info.plist; 678 | LD_RUNPATH_SEARCH_PATHS = ( 679 | "$(inherited)", 680 | "@executable_path/Frameworks", 681 | "@loader_path/Frameworks", 682 | ); 683 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZTableViewUITests; 684 | PRODUCT_NAME = "$(TARGET_NAME)"; 685 | TARGETED_DEVICE_FAMILY = "1,2"; 686 | TEST_TARGET_NAME = WMZTableView; 687 | }; 688 | name = Release; 689 | }; 690 | /* End XCBuildConfiguration section */ 691 | 692 | /* Begin XCConfigurationList section */ 693 | 185EACCC217D9E1900C6B792 /* Build configuration list for PBXProject "WMZTableView" */ = { 694 | isa = XCConfigurationList; 695 | buildConfigurations = ( 696 | 185EACFB217D9E1C00C6B792 /* Debug */, 697 | 185EACFC217D9E1C00C6B792 /* Release */, 698 | ); 699 | defaultConfigurationIsVisible = 0; 700 | defaultConfigurationName = Release; 701 | }; 702 | 185EACFD217D9E1C00C6B792 /* Build configuration list for PBXNativeTarget "WMZTableView" */ = { 703 | isa = XCConfigurationList; 704 | buildConfigurations = ( 705 | 185EACFE217D9E1C00C6B792 /* Debug */, 706 | 185EACFF217D9E1C00C6B792 /* Release */, 707 | ); 708 | defaultConfigurationIsVisible = 0; 709 | defaultConfigurationName = Release; 710 | }; 711 | 185EAD00217D9E1C00C6B792 /* Build configuration list for PBXNativeTarget "WMZTableViewTests" */ = { 712 | isa = XCConfigurationList; 713 | buildConfigurations = ( 714 | 185EAD01217D9E1C00C6B792 /* Debug */, 715 | 185EAD02217D9E1C00C6B792 /* Release */, 716 | ); 717 | defaultConfigurationIsVisible = 0; 718 | defaultConfigurationName = Release; 719 | }; 720 | 185EAD03217D9E1C00C6B792 /* Build configuration list for PBXNativeTarget "WMZTableViewUITests" */ = { 721 | isa = XCConfigurationList; 722 | buildConfigurations = ( 723 | 185EAD04217D9E1C00C6B792 /* Debug */, 724 | 185EAD05217D9E1C00C6B792 /* Release */, 725 | ); 726 | defaultConfigurationIsVisible = 0; 727 | defaultConfigurationName = Release; 728 | }; 729 | /* End XCConfigurationList section */ 730 | }; 731 | rootObject = 185EACC9217D9E1900C6B792 /* Project object */; 732 | } 733 | -------------------------------------------------------------------------------- /WMZTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WMZTableView.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /WMZTableView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WMZTableView 4 | // 5 | // Created by wmz on 2018/10/22. 6 | // Copyright © 2018年 wmz. 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 | -------------------------------------------------------------------------------- /WMZTableView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WMZTableView 4 | // 5 | // Created by wmz on 2018/10/22. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | UINavigationController *NA = [[UINavigationController alloc]initWithRootViewController:[ViewController new]]; 20 | self.window.rootViewController = NA; 21 | // Override point for customization after application launch. 22 | return YES; 23 | } 24 | 25 | 26 | - (void)applicationWillResignActive:(UIApplication *)application { 27 | // 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. 28 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 29 | } 30 | 31 | 32 | - (void)applicationDidEnterBackground:(UIApplication *)application { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | 38 | - (void)applicationWillEnterForeground:(UIApplication *)application { 39 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | 43 | - (void)applicationDidBecomeActive:(UIApplication *)application { 44 | // 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. 45 | } 46 | 47 | 48 | - (void)applicationWillTerminate:(UIApplication *)application { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /WMZTableView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /WMZTableView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /WMZTableView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /WMZTableView/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 | -------------------------------------------------------------------------------- /WMZTableView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /WMZTableView/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 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setInset:(CGFloat)inset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.inset = inset; 135 | } 136 | } 137 | 138 | - (void)setOffset:(CGFloat)offset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.offset = offset; 141 | } 142 | } 143 | 144 | - (void)setSizeOffset:(CGSize)sizeOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.sizeOffset = sizeOffset; 147 | } 148 | } 149 | 150 | - (void)setCenterOffset:(CGPoint)centerOffset { 151 | for (MASConstraint *constraint in self.childConstraints) { 152 | constraint.centerOffset = centerOffset; 153 | } 154 | } 155 | 156 | #pragma mark - MASConstraint 157 | 158 | - (void)activate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint activate]; 161 | } 162 | } 163 | 164 | - (void)deactivate { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | [constraint deactivate]; 167 | } 168 | } 169 | 170 | - (void)install { 171 | for (MASConstraint *constraint in self.childConstraints) { 172 | constraint.updateExisting = self.updateExisting; 173 | [constraint install]; 174 | } 175 | } 176 | 177 | - (void)uninstall { 178 | for (MASConstraint *constraint in self.childConstraints) { 179 | [constraint uninstall]; 180 | } 181 | } 182 | 183 | @end 184 | -------------------------------------------------------------------------------- /WMZTableView/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 | -------------------------------------------------------------------------------- /WMZTableView/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 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 31 | */ 32 | - (MASConstraint * (^)(CGFloat inset))inset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 38 | */ 39 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant, 43 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 44 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 45 | */ 46 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 47 | 48 | /** 49 | * Modifies the NSLayoutConstraint constant 50 | */ 51 | - (MASConstraint * (^)(CGFloat offset))offset; 52 | 53 | /** 54 | * Modifies the NSLayoutConstraint constant based on a value type 55 | */ 56 | - (MASConstraint * (^)(NSValue *value))valueOffset; 57 | 58 | /** 59 | * Sets the NSLayoutConstraint multiplier property 60 | */ 61 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 62 | 63 | /** 64 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 65 | */ 66 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 67 | 68 | /** 69 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 70 | */ 71 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 72 | 73 | /** 74 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 75 | */ 76 | - (MASConstraint * (^)(void))priorityLow; 77 | 78 | /** 79 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 80 | */ 81 | - (MASConstraint * (^)(void))priorityMedium; 82 | 83 | /** 84 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 85 | */ 86 | - (MASConstraint * (^)(void))priorityHigh; 87 | 88 | /** 89 | * Sets the constraint relation to NSLayoutRelationEqual 90 | * returns a block which accepts one of the following: 91 | * MASViewAttribute, UIView, NSValue, NSArray 92 | * see readme for more details. 93 | */ 94 | - (MASConstraint * (^)(id attr))equalTo; 95 | 96 | /** 97 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 98 | * returns a block which accepts one of the following: 99 | * MASViewAttribute, UIView, NSValue, NSArray 100 | * see readme for more details. 101 | */ 102 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 103 | 104 | /** 105 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 106 | * returns a block which accepts one of the following: 107 | * MASViewAttribute, UIView, NSValue, NSArray 108 | * see readme for more details. 109 | */ 110 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 111 | 112 | /** 113 | * Optional semantic property which has no effect but improves the readability of constraint 114 | */ 115 | - (MASConstraint *)with; 116 | 117 | /** 118 | * Optional semantic property which has no effect but improves the readability of constraint 119 | */ 120 | - (MASConstraint *)and; 121 | 122 | /** 123 | * Creates a new MASCompositeConstraint with the called attribute and reciever 124 | */ 125 | - (MASConstraint *)left; 126 | - (MASConstraint *)top; 127 | - (MASConstraint *)right; 128 | - (MASConstraint *)bottom; 129 | - (MASConstraint *)leading; 130 | - (MASConstraint *)trailing; 131 | - (MASConstraint *)width; 132 | - (MASConstraint *)height; 133 | - (MASConstraint *)centerX; 134 | - (MASConstraint *)centerY; 135 | - (MASConstraint *)baseline; 136 | 137 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 138 | 139 | - (MASConstraint *)firstBaseline; 140 | - (MASConstraint *)lastBaseline; 141 | 142 | #endif 143 | 144 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 145 | 146 | - (MASConstraint *)leftMargin; 147 | - (MASConstraint *)rightMargin; 148 | - (MASConstraint *)topMargin; 149 | - (MASConstraint *)bottomMargin; 150 | - (MASConstraint *)leadingMargin; 151 | - (MASConstraint *)trailingMargin; 152 | - (MASConstraint *)centerXWithinMargins; 153 | - (MASConstraint *)centerYWithinMargins; 154 | 155 | #endif 156 | 157 | 158 | /** 159 | * Sets the constraint debug name 160 | */ 161 | - (MASConstraint * (^)(id key))key; 162 | 163 | // NSLayoutConstraint constant Setters 164 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 170 | */ 171 | - (void)setInsets:(MASEdgeInsets)insets; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant, 175 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 176 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 177 | */ 178 | - (void)setInset:(CGFloat)inset; 179 | 180 | /** 181 | * Modifies the NSLayoutConstraint constant, 182 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 183 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 184 | */ 185 | - (void)setSizeOffset:(CGSize)sizeOffset; 186 | 187 | /** 188 | * Modifies the NSLayoutConstraint constant, 189 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 190 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 191 | */ 192 | - (void)setCenterOffset:(CGPoint)centerOffset; 193 | 194 | /** 195 | * Modifies the NSLayoutConstraint constant 196 | */ 197 | - (void)setOffset:(CGFloat)offset; 198 | 199 | 200 | // NSLayoutConstraint Installation support 201 | 202 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 203 | /** 204 | * Whether or not to go through the animator proxy when modifying the constraint 205 | */ 206 | @property (nonatomic, copy, readonly) MASConstraint *animator; 207 | #endif 208 | 209 | /** 210 | * Activates an NSLayoutConstraint if it's supported by an OS. 211 | * Invokes install otherwise. 212 | */ 213 | - (void)activate; 214 | 215 | /** 216 | * Deactivates previously installed/activated NSLayoutConstraint. 217 | */ 218 | - (void)deactivate; 219 | 220 | /** 221 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 222 | */ 223 | - (void)install; 224 | 225 | /** 226 | * Removes previously installed NSLayoutConstraint 227 | */ 228 | - (void)uninstall; 229 | 230 | @end 231 | 232 | 233 | /** 234 | * Convenience auto-boxing macros for MASConstraint methods. 235 | * 236 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 237 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 238 | */ 239 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 240 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 241 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 242 | 243 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 244 | 245 | 246 | #ifdef MAS_SHORTHAND_GLOBALS 247 | 248 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 249 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 250 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 251 | 252 | #define offset(...) mas_offset(__VA_ARGS__) 253 | 254 | #endif 255 | 256 | 257 | @interface MASConstraint (AutoboxingSupport) 258 | 259 | /** 260 | * Aliases to corresponding relation methods (for shorthand macros) 261 | * Also needed to aid autocompletion 262 | */ 263 | - (MASConstraint * (^)(id attr))mas_equalTo; 264 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 265 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 266 | 267 | /** 268 | * A dummy method to aid autocompletion 269 | */ 270 | - (MASConstraint * (^)(id offset))mas_offset; 271 | 272 | @end 273 | -------------------------------------------------------------------------------- /WMZTableView/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 * (^)(void))priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)(void))priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)(void))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 * (^)(CGFloat))inset { 96 | return ^id(CGFloat inset){ 97 | self.inset = inset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGSize))sizeOffset { 103 | return ^id(CGSize offset) { 104 | self.sizeOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGPoint))centerOffset { 110 | return ^id(CGPoint offset) { 111 | self.centerOffset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(CGFloat))offset { 117 | return ^id(CGFloat offset){ 118 | self.offset = offset; 119 | return self; 120 | }; 121 | } 122 | 123 | - (MASConstraint * (^)(NSValue *value))valueOffset { 124 | return ^id(NSValue *offset) { 125 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 126 | [self setLayoutConstantWithValue:offset]; 127 | return self; 128 | }; 129 | } 130 | 131 | - (MASConstraint * (^)(id offset))mas_offset { 132 | // Will never be called due to macro 133 | return nil; 134 | } 135 | 136 | #pragma mark - NSLayoutConstraint constant setter 137 | 138 | - (void)setLayoutConstantWithValue:(NSValue *)value { 139 | if ([value isKindOfClass:NSNumber.class]) { 140 | self.offset = [(NSNumber *)value doubleValue]; 141 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 142 | CGPoint point; 143 | [value getValue:&point]; 144 | self.centerOffset = point; 145 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 146 | CGSize size; 147 | [value getValue:&size]; 148 | self.sizeOffset = size; 149 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 150 | MASEdgeInsets insets; 151 | [value getValue:&insets]; 152 | self.insets = insets; 153 | } else { 154 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 155 | } 156 | } 157 | 158 | #pragma mark - Semantic properties 159 | 160 | - (MASConstraint *)with { 161 | return self; 162 | } 163 | 164 | - (MASConstraint *)and { 165 | return self; 166 | } 167 | 168 | #pragma mark - Chaining 169 | 170 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 171 | MASMethodNotImplemented(); 172 | } 173 | 174 | - (MASConstraint *)left { 175 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 176 | } 177 | 178 | - (MASConstraint *)top { 179 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 180 | } 181 | 182 | - (MASConstraint *)right { 183 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 184 | } 185 | 186 | - (MASConstraint *)bottom { 187 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 188 | } 189 | 190 | - (MASConstraint *)leading { 191 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 192 | } 193 | 194 | - (MASConstraint *)trailing { 195 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 196 | } 197 | 198 | - (MASConstraint *)width { 199 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 200 | } 201 | 202 | - (MASConstraint *)height { 203 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 204 | } 205 | 206 | - (MASConstraint *)centerX { 207 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 208 | } 209 | 210 | - (MASConstraint *)centerY { 211 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 212 | } 213 | 214 | - (MASConstraint *)baseline { 215 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 216 | } 217 | 218 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 219 | 220 | - (MASConstraint *)firstBaseline { 221 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 222 | } 223 | - (MASConstraint *)lastBaseline { 224 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 225 | } 226 | 227 | #endif 228 | 229 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 230 | 231 | - (MASConstraint *)leftMargin { 232 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 233 | } 234 | 235 | - (MASConstraint *)rightMargin { 236 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 237 | } 238 | 239 | - (MASConstraint *)topMargin { 240 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 241 | } 242 | 243 | - (MASConstraint *)bottomMargin { 244 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 245 | } 246 | 247 | - (MASConstraint *)leadingMargin { 248 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 249 | } 250 | 251 | - (MASConstraint *)trailingMargin { 252 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 253 | } 254 | 255 | - (MASConstraint *)centerXWithinMargins { 256 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 257 | } 258 | 259 | - (MASConstraint *)centerYWithinMargins { 260 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 261 | } 262 | 263 | #endif 264 | 265 | #pragma mark - Abstract 266 | 267 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 268 | 269 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 270 | 271 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 272 | 273 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 274 | 275 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 276 | 277 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 278 | 279 | - (void)setInset:(CGFloat __unused)inset { MASMethodNotImplemented(); } 280 | 281 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 282 | 283 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 284 | 285 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 286 | 287 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 288 | 289 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 290 | 291 | #endif 292 | 293 | - (void)activate { MASMethodNotImplemented(); } 294 | 295 | - (void)deactivate { MASMethodNotImplemented(); } 296 | 297 | - (void)install { MASMethodNotImplemented(); } 298 | 299 | - (void)uninstall { MASMethodNotImplemented(); } 300 | 301 | @end 302 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintMaker.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 26 | 27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline, 28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline, 29 | 30 | #endif 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 33 | 34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 42 | 43 | #endif 44 | 45 | }; 46 | 47 | /** 48 | * Provides factory methods for creating MASConstraints. 49 | * Constraints are collected until they are ready to be installed 50 | * 51 | */ 52 | @interface MASConstraintMaker : NSObject 53 | 54 | /** 55 | * The following properties return a new MASViewConstraint 56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 57 | */ 58 | @property (nonatomic, strong, readonly) MASConstraint *left; 59 | @property (nonatomic, strong, readonly) MASConstraint *top; 60 | @property (nonatomic, strong, readonly) MASConstraint *right; 61 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 62 | @property (nonatomic, strong, readonly) MASConstraint *leading; 63 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 64 | @property (nonatomic, strong, readonly) MASConstraint *width; 65 | @property (nonatomic, strong, readonly) MASConstraint *height; 66 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 67 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 68 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 69 | 70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 71 | 72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline; 73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline; 74 | 75 | #endif 76 | 77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 78 | 79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 87 | 88 | #endif 89 | 90 | /** 91 | * Returns a block which creates a new MASCompositeConstraint with the first item set 92 | * to the makers associated view and children corresponding to the set bits in the 93 | * MASAttribute parameter. Combine multiple attributes via binary-or. 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *edges; 103 | 104 | /** 105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 106 | * which generates the appropriate MASViewConstraint children (width, height) 107 | * with the first item set to the makers associated view 108 | */ 109 | @property (nonatomic, strong, readonly) MASConstraint *size; 110 | 111 | /** 112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 113 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 114 | * with the first item set to the makers associated view 115 | */ 116 | @property (nonatomic, strong, readonly) MASConstraint *center; 117 | 118 | /** 119 | * Whether or not to check for an existing constraint instead of adding constraint 120 | */ 121 | @property (nonatomic, assign) BOOL updateExisting; 122 | 123 | /** 124 | * Whether or not to remove existing constraints prior to installing 125 | */ 126 | @property (nonatomic, assign) BOOL removeExisting; 127 | 128 | /** 129 | * initialises the maker with a default view 130 | * 131 | * @param view any MASConstraint are created with this view as the first item 132 | * 133 | * @return a new MASConstraintMaker 134 | */ 135 | - (id)initWithView:(MAS_VIEW *)view; 136 | 137 | /** 138 | * Calls install method on any MASConstraints which have been created by this maker 139 | * 140 | * @return an array of all the installed MASConstraints 141 | */ 142 | - (NSArray *)install; 143 | 144 | - (MASConstraint * (^)(dispatch_block_t))group; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/MASConstraintMaker.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintMaker.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraintMaker.h" 10 | #import "MASViewConstraint.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASConstraint+Private.h" 13 | #import "MASViewAttribute.h" 14 | #import "View+MASAdditions.h" 15 | 16 | @interface MASConstraintMaker () 17 | 18 | @property (nonatomic, weak) MAS_VIEW *view; 19 | @property (nonatomic, strong) NSMutableArray *constraints; 20 | 21 | @end 22 | 23 | @implementation MASConstraintMaker 24 | 25 | - (id)initWithView:(MAS_VIEW *)view { 26 | self = [super init]; 27 | if (!self) return nil; 28 | 29 | self.view = view; 30 | self.constraints = NSMutableArray.new; 31 | 32 | return self; 33 | } 34 | 35 | - (NSArray *)install { 36 | if (self.removeExisting) { 37 | NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view]; 38 | for (MASConstraint *constraint in installedConstraints) { 39 | [constraint uninstall]; 40 | } 41 | } 42 | NSArray *constraints = self.constraints.copy; 43 | for (MASConstraint *constraint in constraints) { 44 | constraint.updateExisting = self.updateExisting; 45 | [constraint install]; 46 | } 47 | [self.constraints removeAllObjects]; 48 | return constraints; 49 | } 50 | 51 | #pragma mark - MASConstraintDelegate 52 | 53 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 54 | NSUInteger index = [self.constraints indexOfObject:constraint]; 55 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 56 | [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint]; 57 | } 58 | 59 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 60 | MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute]; 61 | MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute]; 62 | if ([constraint isKindOfClass:MASViewConstraint.class]) { 63 | //replace with composite constraint 64 | NSArray *children = @[constraint, newConstraint]; 65 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 66 | compositeConstraint.delegate = self; 67 | [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint]; 68 | return compositeConstraint; 69 | } 70 | if (!constraint) { 71 | newConstraint.delegate = self; 72 | [self.constraints addObject:newConstraint]; 73 | } 74 | return newConstraint; 75 | } 76 | 77 | - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs { 78 | __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading 79 | | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX 80 | | MASAttributeCenterY | MASAttributeBaseline 81 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 82 | | MASAttributeFirstBaseline | MASAttributeLastBaseline 83 | #endif 84 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 85 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin 86 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins 87 | | MASAttributeCenterYWithinMargins 88 | #endif 89 | ); 90 | 91 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); 92 | 93 | NSMutableArray *attributes = [NSMutableArray array]; 94 | 95 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; 96 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; 97 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; 98 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; 99 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; 100 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; 101 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; 102 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; 103 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; 104 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; 105 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; 106 | 107 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 108 | 109 | if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline]; 110 | if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline]; 111 | 112 | #endif 113 | 114 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 115 | 116 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin]; 117 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin]; 118 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin]; 119 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin]; 120 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin]; 121 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin]; 122 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins]; 123 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins]; 124 | 125 | #endif 126 | 127 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; 128 | 129 | for (MASViewAttribute *a in attributes) { 130 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; 131 | } 132 | 133 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 134 | constraint.delegate = self; 135 | [self.constraints addObject:constraint]; 136 | return constraint; 137 | } 138 | 139 | #pragma mark - standard Attributes 140 | 141 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 142 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; 143 | } 144 | 145 | - (MASConstraint *)left { 146 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 147 | } 148 | 149 | - (MASConstraint *)top { 150 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 151 | } 152 | 153 | - (MASConstraint *)right { 154 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 155 | } 156 | 157 | - (MASConstraint *)bottom { 158 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 159 | } 160 | 161 | - (MASConstraint *)leading { 162 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 163 | } 164 | 165 | - (MASConstraint *)trailing { 166 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 167 | } 168 | 169 | - (MASConstraint *)width { 170 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 171 | } 172 | 173 | - (MASConstraint *)height { 174 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 175 | } 176 | 177 | - (MASConstraint *)centerX { 178 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 179 | } 180 | 181 | - (MASConstraint *)centerY { 182 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 183 | } 184 | 185 | - (MASConstraint *)baseline { 186 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 187 | } 188 | 189 | - (MASConstraint *(^)(MASAttribute))attributes { 190 | return ^(MASAttribute attrs){ 191 | return [self addConstraintWithAttributes:attrs]; 192 | }; 193 | } 194 | 195 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 196 | 197 | - (MASConstraint *)firstBaseline { 198 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 199 | } 200 | 201 | - (MASConstraint *)lastBaseline { 202 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 203 | } 204 | 205 | #endif 206 | 207 | 208 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 209 | 210 | - (MASConstraint *)leftMargin { 211 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 212 | } 213 | 214 | - (MASConstraint *)rightMargin { 215 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 216 | } 217 | 218 | - (MASConstraint *)topMargin { 219 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 220 | } 221 | 222 | - (MASConstraint *)bottomMargin { 223 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 224 | } 225 | 226 | - (MASConstraint *)leadingMargin { 227 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 228 | } 229 | 230 | - (MASConstraint *)trailingMargin { 231 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 232 | } 233 | 234 | - (MASConstraint *)centerXWithinMargins { 235 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 236 | } 237 | 238 | - (MASConstraint *)centerYWithinMargins { 239 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 240 | } 241 | 242 | #endif 243 | 244 | 245 | #pragma mark - composite Attributes 246 | 247 | - (MASConstraint *)edges { 248 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; 249 | } 250 | 251 | - (MASConstraint *)size { 252 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; 253 | } 254 | 255 | - (MASConstraint *)center { 256 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; 257 | } 258 | 259 | #pragma mark - grouping 260 | 261 | - (MASConstraint *(^)(dispatch_block_t group))group { 262 | return ^id(dispatch_block_t group) { 263 | NSInteger previousCount = self.constraints.count; 264 | group(); 265 | 266 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; 267 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 268 | constraint.delegate = self; 269 | return constraint; 270 | }; 271 | } 272 | 273 | @end 274 | -------------------------------------------------------------------------------- /WMZTableView/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 | -------------------------------------------------------------------------------- /WMZTableView/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 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | #if TARGET_OS_IPHONE || TARGET_OS_TV 14 | 15 | #import 16 | #define MAS_VIEW UIView 17 | #define MAS_VIEW_CONTROLLER UIViewController 18 | #define MASEdgeInsets UIEdgeInsets 19 | 20 | typedef UILayoutPriority MASLayoutPriority; 21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 26 | 27 | #elif TARGET_OS_MAC 28 | 29 | #import 30 | #define MAS_VIEW NSView 31 | #define MASEdgeInsets NSEdgeInsets 32 | 33 | typedef NSLayoutPriority MASLayoutPriority; 34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 42 | 43 | #endif 44 | 45 | /** 46 | * Allows you to attach keys to objects matching the variable names passed. 47 | * 48 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 49 | * 50 | * is equivalent to: 51 | * 52 | * MASAttachKeys(view1, view2); 53 | */ 54 | #define MASAttachKeys(...) \ 55 | { \ 56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 57 | for (id key in keyPairs.allKeys) { \ 58 | id obj = keyPairs[key]; \ 59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 60 | @"Cannot attach mas_key to %@", obj); \ 61 | [obj setMas_key:key]; \ 62 | } \ 63 | } 64 | 65 | /** 66 | * Used to create object hashes 67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 68 | */ 69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 71 | 72 | /** 73 | * Given a scalar or struct value, wraps it in NSValue 74 | * Based on EXPObjectify: https://github.com/specta/expecta 75 | */ 76 | static inline id _MASBoxValue(const char *type, ...) { 77 | va_list v; 78 | va_start(v, type); 79 | id obj = nil; 80 | if (strcmp(type, @encode(id)) == 0) { 81 | id actual = va_arg(v, id); 82 | obj = actual; 83 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 85 | obj = [NSValue value:&actual withObjCType:type]; 86 | } else if (strcmp(type, @encode(CGSize)) == 0) { 87 | CGSize actual = (CGSize)va_arg(v, CGSize); 88 | obj = [NSValue value:&actual withObjCType:type]; 89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 91 | obj = [NSValue value:&actual withObjCType:type]; 92 | } else if (strcmp(type, @encode(double)) == 0) { 93 | double actual = (double)va_arg(v, double); 94 | obj = [NSNumber numberWithDouble:actual]; 95 | } else if (strcmp(type, @encode(float)) == 0) { 96 | float actual = (float)va_arg(v, double); 97 | obj = [NSNumber numberWithFloat:actual]; 98 | } else if (strcmp(type, @encode(int)) == 0) { 99 | int actual = (int)va_arg(v, int); 100 | obj = [NSNumber numberWithInt:actual]; 101 | } else if (strcmp(type, @encode(long)) == 0) { 102 | long actual = (long)va_arg(v, long); 103 | obj = [NSNumber numberWithLong:actual]; 104 | } else if (strcmp(type, @encode(long long)) == 0) { 105 | long long actual = (long long)va_arg(v, long long); 106 | obj = [NSNumber numberWithLongLong:actual]; 107 | } else if (strcmp(type, @encode(short)) == 0) { 108 | short actual = (short)va_arg(v, int); 109 | obj = [NSNumber numberWithShort:actual]; 110 | } else if (strcmp(type, @encode(char)) == 0) { 111 | char actual = (char)va_arg(v, int); 112 | obj = [NSNumber numberWithChar:actual]; 113 | } else if (strcmp(type, @encode(bool)) == 0) { 114 | bool actual = (bool)va_arg(v, int); 115 | obj = [NSNumber numberWithBool:actual]; 116 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 118 | obj = [NSNumber numberWithUnsignedChar:actual]; 119 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 121 | obj = [NSNumber numberWithUnsignedInt:actual]; 122 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 124 | obj = [NSNumber numberWithUnsignedLong:actual]; 125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 127 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 128 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 130 | obj = [NSNumber numberWithUnsignedShort:actual]; 131 | } 132 | va_end(v); 133 | return obj; 134 | } 135 | 136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 137 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/MASViewConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASLayoutConstraint.h" 13 | #import "View+MASAdditions.h" 14 | #import 15 | 16 | @interface MAS_VIEW (MASConstraints) 17 | 18 | @property (nonatomic, readonly) NSMutableSet *mas_installedConstraints; 19 | 20 | @end 21 | 22 | @implementation MAS_VIEW (MASConstraints) 23 | 24 | static char kInstalledConstraintsKey; 25 | 26 | - (NSMutableSet *)mas_installedConstraints { 27 | NSMutableSet *constraints = objc_getAssociatedObject(self, &kInstalledConstraintsKey); 28 | if (!constraints) { 29 | constraints = [NSMutableSet set]; 30 | objc_setAssociatedObject(self, &kInstalledConstraintsKey, constraints, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 31 | } 32 | return constraints; 33 | } 34 | 35 | @end 36 | 37 | 38 | @interface MASViewConstraint () 39 | 40 | @property (nonatomic, strong, readwrite) MASViewAttribute *secondViewAttribute; 41 | @property (nonatomic, weak) MAS_VIEW *installedView; 42 | @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint; 43 | @property (nonatomic, assign) NSLayoutRelation layoutRelation; 44 | @property (nonatomic, assign) MASLayoutPriority layoutPriority; 45 | @property (nonatomic, assign) CGFloat layoutMultiplier; 46 | @property (nonatomic, assign) CGFloat layoutConstant; 47 | @property (nonatomic, assign) BOOL hasLayoutRelation; 48 | @property (nonatomic, strong) id mas_key; 49 | @property (nonatomic, assign) BOOL useAnimator; 50 | 51 | @end 52 | 53 | @implementation MASViewConstraint 54 | 55 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute { 56 | self = [super init]; 57 | if (!self) return nil; 58 | 59 | _firstViewAttribute = firstViewAttribute; 60 | self.layoutPriority = MASLayoutPriorityRequired; 61 | self.layoutMultiplier = 1; 62 | 63 | return self; 64 | } 65 | 66 | #pragma mark - NSCoping 67 | 68 | - (id)copyWithZone:(NSZone __unused *)zone { 69 | MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute]; 70 | constraint.layoutConstant = self.layoutConstant; 71 | constraint.layoutRelation = self.layoutRelation; 72 | constraint.layoutPriority = self.layoutPriority; 73 | constraint.layoutMultiplier = self.layoutMultiplier; 74 | constraint.delegate = self.delegate; 75 | return constraint; 76 | } 77 | 78 | #pragma mark - Public 79 | 80 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view { 81 | return [view.mas_installedConstraints allObjects]; 82 | } 83 | 84 | #pragma mark - Private 85 | 86 | - (void)setLayoutConstant:(CGFloat)layoutConstant { 87 | _layoutConstant = layoutConstant; 88 | 89 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 90 | if (self.useAnimator) { 91 | [self.layoutConstraint.animator setConstant:layoutConstant]; 92 | } else { 93 | self.layoutConstraint.constant = layoutConstant; 94 | } 95 | #else 96 | self.layoutConstraint.constant = layoutConstant; 97 | #endif 98 | } 99 | 100 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation { 101 | _layoutRelation = layoutRelation; 102 | self.hasLayoutRelation = YES; 103 | } 104 | 105 | - (BOOL)supportsActiveProperty { 106 | return [self.layoutConstraint respondsToSelector:@selector(isActive)]; 107 | } 108 | 109 | - (BOOL)isActive { 110 | BOOL active = YES; 111 | if ([self supportsActiveProperty]) { 112 | active = [self.layoutConstraint isActive]; 113 | } 114 | 115 | return active; 116 | } 117 | 118 | - (BOOL)hasBeenInstalled { 119 | return (self.layoutConstraint != nil) && [self isActive]; 120 | } 121 | 122 | - (void)setSecondViewAttribute:(id)secondViewAttribute { 123 | if ([secondViewAttribute isKindOfClass:NSValue.class]) { 124 | [self setLayoutConstantWithValue:secondViewAttribute]; 125 | } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) { 126 | _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute]; 127 | } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) { 128 | _secondViewAttribute = secondViewAttribute; 129 | } else { 130 | NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute); 131 | } 132 | } 133 | 134 | #pragma mark - NSLayoutConstraint multiplier proxies 135 | 136 | - (MASConstraint * (^)(CGFloat))multipliedBy { 137 | return ^id(CGFloat multiplier) { 138 | NSAssert(!self.hasBeenInstalled, 139 | @"Cannot modify constraint multiplier after it has been installed"); 140 | 141 | self.layoutMultiplier = multiplier; 142 | return self; 143 | }; 144 | } 145 | 146 | 147 | - (MASConstraint * (^)(CGFloat))dividedBy { 148 | return ^id(CGFloat divider) { 149 | NSAssert(!self.hasBeenInstalled, 150 | @"Cannot modify constraint multiplier after it has been installed"); 151 | 152 | self.layoutMultiplier = 1.0/divider; 153 | return self; 154 | }; 155 | } 156 | 157 | #pragma mark - MASLayoutPriority proxy 158 | 159 | - (MASConstraint * (^)(MASLayoutPriority))priority { 160 | return ^id(MASLayoutPriority priority) { 161 | NSAssert(!self.hasBeenInstalled, 162 | @"Cannot modify constraint priority after it has been installed"); 163 | 164 | self.layoutPriority = priority; 165 | return self; 166 | }; 167 | } 168 | 169 | #pragma mark - NSLayoutRelation proxy 170 | 171 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 172 | return ^id(id attribute, NSLayoutRelation relation) { 173 | if ([attribute isKindOfClass:NSArray.class]) { 174 | NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation"); 175 | NSMutableArray *children = NSMutableArray.new; 176 | for (id attr in attribute) { 177 | MASViewConstraint *viewConstraint = [self copy]; 178 | viewConstraint.layoutRelation = relation; 179 | viewConstraint.secondViewAttribute = attr; 180 | [children addObject:viewConstraint]; 181 | } 182 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 183 | compositeConstraint.delegate = self.delegate; 184 | [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint]; 185 | return compositeConstraint; 186 | } else { 187 | NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation"); 188 | self.layoutRelation = relation; 189 | self.secondViewAttribute = attribute; 190 | return self; 191 | } 192 | }; 193 | } 194 | 195 | #pragma mark - Semantic properties 196 | 197 | - (MASConstraint *)with { 198 | return self; 199 | } 200 | 201 | - (MASConstraint *)and { 202 | return self; 203 | } 204 | 205 | #pragma mark - attribute chaining 206 | 207 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 208 | NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation"); 209 | 210 | return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 211 | } 212 | 213 | #pragma mark - Animator proxy 214 | 215 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 216 | 217 | - (MASConstraint *)animator { 218 | self.useAnimator = YES; 219 | return self; 220 | } 221 | 222 | #endif 223 | 224 | #pragma mark - debug helpers 225 | 226 | - (MASConstraint * (^)(id))key { 227 | return ^id(id key) { 228 | self.mas_key = key; 229 | return self; 230 | }; 231 | } 232 | 233 | #pragma mark - NSLayoutConstraint constant setters 234 | 235 | - (void)setInsets:(MASEdgeInsets)insets { 236 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 237 | switch (layoutAttribute) { 238 | case NSLayoutAttributeLeft: 239 | case NSLayoutAttributeLeading: 240 | self.layoutConstant = insets.left; 241 | break; 242 | case NSLayoutAttributeTop: 243 | self.layoutConstant = insets.top; 244 | break; 245 | case NSLayoutAttributeBottom: 246 | self.layoutConstant = -insets.bottom; 247 | break; 248 | case NSLayoutAttributeRight: 249 | case NSLayoutAttributeTrailing: 250 | self.layoutConstant = -insets.right; 251 | break; 252 | default: 253 | break; 254 | } 255 | } 256 | 257 | - (void)setInset:(CGFloat)inset { 258 | [self setInsets:(MASEdgeInsets){.top = inset, .left = inset, .bottom = inset, .right = inset}]; 259 | } 260 | 261 | - (void)setOffset:(CGFloat)offset { 262 | self.layoutConstant = offset; 263 | } 264 | 265 | - (void)setSizeOffset:(CGSize)sizeOffset { 266 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 267 | switch (layoutAttribute) { 268 | case NSLayoutAttributeWidth: 269 | self.layoutConstant = sizeOffset.width; 270 | break; 271 | case NSLayoutAttributeHeight: 272 | self.layoutConstant = sizeOffset.height; 273 | break; 274 | default: 275 | break; 276 | } 277 | } 278 | 279 | - (void)setCenterOffset:(CGPoint)centerOffset { 280 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 281 | switch (layoutAttribute) { 282 | case NSLayoutAttributeCenterX: 283 | self.layoutConstant = centerOffset.x; 284 | break; 285 | case NSLayoutAttributeCenterY: 286 | self.layoutConstant = centerOffset.y; 287 | break; 288 | default: 289 | break; 290 | } 291 | } 292 | 293 | #pragma mark - MASConstraint 294 | 295 | - (void)activate { 296 | [self install]; 297 | } 298 | 299 | - (void)deactivate { 300 | [self uninstall]; 301 | } 302 | 303 | - (void)install { 304 | if (self.hasBeenInstalled) { 305 | return; 306 | } 307 | 308 | if ([self supportsActiveProperty] && self.layoutConstraint) { 309 | self.layoutConstraint.active = YES; 310 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; 311 | return; 312 | } 313 | 314 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item; 315 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute; 316 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item; 317 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute; 318 | 319 | // alignment attributes must have a secondViewAttribute 320 | // therefore we assume that is refering to superview 321 | // eg make.left.equalTo(@10) 322 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) { 323 | secondLayoutItem = self.firstViewAttribute.view.superview; 324 | secondLayoutAttribute = firstLayoutAttribute; 325 | } 326 | 327 | MASLayoutConstraint *layoutConstraint 328 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem 329 | attribute:firstLayoutAttribute 330 | relatedBy:self.layoutRelation 331 | toItem:secondLayoutItem 332 | attribute:secondLayoutAttribute 333 | multiplier:self.layoutMultiplier 334 | constant:self.layoutConstant]; 335 | 336 | layoutConstraint.priority = self.layoutPriority; 337 | layoutConstraint.mas_key = self.mas_key; 338 | 339 | if (self.secondViewAttribute.view) { 340 | MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view]; 341 | NSAssert(closestCommonSuperview, 342 | @"couldn't find a common superview for %@ and %@", 343 | self.firstViewAttribute.view, self.secondViewAttribute.view); 344 | self.installedView = closestCommonSuperview; 345 | } else if (self.firstViewAttribute.isSizeAttribute) { 346 | self.installedView = self.firstViewAttribute.view; 347 | } else { 348 | self.installedView = self.firstViewAttribute.view.superview; 349 | } 350 | 351 | 352 | MASLayoutConstraint *existingConstraint = nil; 353 | if (self.updateExisting) { 354 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint]; 355 | } 356 | if (existingConstraint) { 357 | // just update the constant 358 | existingConstraint.constant = layoutConstraint.constant; 359 | self.layoutConstraint = existingConstraint; 360 | } else { 361 | [self.installedView addConstraint:layoutConstraint]; 362 | self.layoutConstraint = layoutConstraint; 363 | [firstLayoutItem.mas_installedConstraints addObject:self]; 364 | } 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 | if ([self supportsActiveProperty]) { 389 | self.layoutConstraint.active = NO; 390 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 391 | return; 392 | } 393 | 394 | [self.installedView removeConstraint:self.layoutConstraint]; 395 | self.layoutConstraint = nil; 396 | self.installedView = nil; 397 | 398 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 399 | } 400 | 401 | @end 402 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 42 | if (self.count < 2) { 43 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 44 | return; 45 | } 46 | 47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 48 | if (axisType == MASAxisTypeHorizontal) { 49 | MAS_VIEW *prev; 50 | for (int i = 0; i < self.count; i++) { 51 | MAS_VIEW *v = self[i]; 52 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 53 | if (prev) { 54 | make.width.equalTo(prev); 55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing); 56 | if (i == self.count - 1) {//last one 57 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 58 | } 59 | } 60 | else {//first one 61 | make.left.equalTo(tempSuperView).offset(leadSpacing); 62 | } 63 | 64 | }]; 65 | prev = v; 66 | } 67 | } 68 | else { 69 | MAS_VIEW *prev; 70 | for (int i = 0; i < self.count; i++) { 71 | MAS_VIEW *v = self[i]; 72 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 73 | if (prev) { 74 | make.height.equalTo(prev); 75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing); 76 | if (i == self.count - 1) {//last one 77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 78 | } 79 | } 80 | else {//first one 81 | make.top.equalTo(tempSuperView).offset(leadSpacing); 82 | } 83 | 84 | }]; 85 | prev = v; 86 | } 87 | } 88 | } 89 | 90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 91 | if (self.count < 2) { 92 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 93 | return; 94 | } 95 | 96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 97 | if (axisType == MASAxisTypeHorizontal) { 98 | MAS_VIEW *prev; 99 | for (int i = 0; i < self.count; i++) { 100 | MAS_VIEW *v = self[i]; 101 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 102 | make.width.equalTo(@(fixedItemLength)); 103 | if (prev) { 104 | if (i == self.count - 1) {//last one 105 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 106 | } 107 | else { 108 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 110 | } 111 | } 112 | else {//first one 113 | make.left.equalTo(tempSuperView).offset(leadSpacing); 114 | } 115 | }]; 116 | prev = v; 117 | } 118 | } 119 | else { 120 | MAS_VIEW *prev; 121 | for (int i = 0; i < self.count; i++) { 122 | MAS_VIEW *v = self[i]; 123 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 124 | make.height.equalTo(@(fixedItemLength)); 125 | if (prev) { 126 | if (i == self.count - 1) {//last one 127 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 128 | } 129 | else { 130 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 131 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 132 | } 133 | } 134 | else {//first one 135 | make.top.equalTo(tempSuperView).offset(leadSpacing); 136 | } 137 | }]; 138 | prev = v; 139 | } 140 | } 141 | } 142 | 143 | - (MAS_VIEW *)mas_commonSuperviewOfViews 144 | { 145 | MAS_VIEW *commonSuperview = nil; 146 | MAS_VIEW *previousView = nil; 147 | for (id object in self) { 148 | if ([object isKindOfClass:[MAS_VIEW class]]) { 149 | MAS_VIEW *view = (MAS_VIEW *)object; 150 | if (previousView) { 151 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 152 | } else { 153 | commonSuperview = view; 154 | } 155 | previousView = view; 156 | } 157 | } 158 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy."); 159 | return commonSuperview; 160 | } 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /WMZTableView/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 | -------------------------------------------------------------------------------- /WMZTableView/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 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 48 | @(NSLayoutAttributeFirstBaseline) : @"firstBaseline", 49 | @(NSLayoutAttributeLastBaseline) : @"lastBaseline", 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 54 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 55 | @(NSLayoutAttributeTopMargin) : @"topMargin", 56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 61 | #endif 62 | 63 | }; 64 | 65 | }); 66 | return descriptionMap; 67 | } 68 | 69 | 70 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 71 | static dispatch_once_t once; 72 | static NSDictionary *descriptionMap; 73 | dispatch_once(&once, ^{ 74 | #if TARGET_OS_IPHONE || TARGET_OS_TV 75 | descriptionMap = @{ 76 | @(MASLayoutPriorityDefaultHigh) : @"high", 77 | @(MASLayoutPriorityDefaultLow) : @"low", 78 | @(MASLayoutPriorityDefaultMedium) : @"medium", 79 | @(MASLayoutPriorityRequired) : @"required", 80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 81 | }; 82 | #elif TARGET_OS_MAC 83 | descriptionMap = @{ 84 | @(MASLayoutPriorityDefaultHigh) : @"high", 85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 86 | @(MASLayoutPriorityDefaultMedium) : @"medium", 87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 89 | @(MASLayoutPriorityDefaultLow) : @"low", 90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 91 | @(MASLayoutPriorityRequired) : @"required", 92 | }; 93 | #endif 94 | }); 95 | return descriptionMap; 96 | } 97 | 98 | #pragma mark - description override 99 | 100 | + (NSString *)descriptionForObject:(id)obj { 101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 103 | } 104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 105 | } 106 | 107 | - (NSString *)description { 108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 109 | 110 | [description appendString:[self.class descriptionForObject:self]]; 111 | 112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]]; 115 | } 116 | 117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]]; 118 | 119 | if (self.secondItem) { 120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 121 | } 122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]]; 124 | } 125 | 126 | if (self.multiplier != 1) { 127 | [description appendFormat:@" * %g", self.multiplier]; 128 | } 129 | 130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 131 | [description appendFormat:@" %g", self.constant]; 132 | } else { 133 | if (self.constant) { 134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 135 | } 136 | } 137 | 138 | if (self.priority != MASLayoutPriorityRequired) { 139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 140 | } 141 | 142 | [description appendString:@">"]; 143 | return description; 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline; 39 | 40 | #endif 41 | 42 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 43 | 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 52 | 53 | #endif 54 | 55 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 56 | 57 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 59 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 60 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 61 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 62 | 63 | #endif 64 | 65 | /** 66 | * a key to associate with this view 67 | */ 68 | @property (nonatomic, strong) id mas_key; 69 | 70 | /** 71 | * Finds the closest common superview between this view and another view 72 | * 73 | * @param view other view 74 | * 75 | * @return returns nil if common superview could not be found 76 | */ 77 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 78 | 79 | /** 80 | * Creates a MASConstraintMaker with the callee view. 81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 82 | * 83 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 84 | * 85 | * @return Array of created MASConstraints 86 | */ 87 | - (NSArray *)mas_makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 88 | 89 | /** 90 | * Creates a MASConstraintMaker with the callee view. 91 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 92 | * If an existing constraint exists then it will be updated instead. 93 | * 94 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 95 | * 96 | * @return Array of created/updated MASConstraints 97 | */ 98 | - (NSArray *)mas_updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 99 | 100 | /** 101 | * Creates a MASConstraintMaker with the callee view. 102 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 103 | * All constraints previously installed for the view will be removed. 104 | * 105 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 106 | * 107 | * @return Array of created/updated MASConstraints 108 | */ 109 | - (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 91 | 92 | - (MASViewAttribute *)mas_firstBaseline { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline]; 94 | } 95 | - (MASViewAttribute *)mas_lastBaseline { 96 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline]; 97 | } 98 | 99 | #endif 100 | 101 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 102 | 103 | - (MASViewAttribute *)mas_leftMargin { 104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 105 | } 106 | 107 | - (MASViewAttribute *)mas_rightMargin { 108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 109 | } 110 | 111 | - (MASViewAttribute *)mas_topMargin { 112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 113 | } 114 | 115 | - (MASViewAttribute *)mas_bottomMargin { 116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 117 | } 118 | 119 | - (MASViewAttribute *)mas_leadingMargin { 120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 121 | } 122 | 123 | - (MASViewAttribute *)mas_trailingMargin { 124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 125 | } 126 | 127 | - (MASViewAttribute *)mas_centerXWithinMargins { 128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 129 | } 130 | 131 | - (MASViewAttribute *)mas_centerYWithinMargins { 132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 133 | } 134 | 135 | #endif 136 | 137 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 138 | 139 | - (MASViewAttribute *)mas_safeAreaLayoutGuide { 140 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 141 | } 142 | - (MASViewAttribute *)mas_safeAreaLayoutGuideTop { 143 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 144 | } 145 | - (MASViewAttribute *)mas_safeAreaLayoutGuideBottom { 146 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 147 | } 148 | - (MASViewAttribute *)mas_safeAreaLayoutGuideLeft { 149 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft]; 150 | } 151 | - (MASViewAttribute *)mas_safeAreaLayoutGuideRight { 152 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight]; 153 | } 154 | 155 | #endif 156 | 157 | #pragma mark - associated properties 158 | 159 | - (id)mas_key { 160 | return objc_getAssociatedObject(self, @selector(mas_key)); 161 | } 162 | 163 | - (void)setMas_key:(id)key { 164 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 165 | } 166 | 167 | #pragma mark - heirachy 168 | 169 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 170 | MAS_VIEW *closestCommonSuperview = nil; 171 | 172 | MAS_VIEW *secondViewSuperview = view; 173 | while (!closestCommonSuperview && secondViewSuperview) { 174 | MAS_VIEW *firstViewSuperview = self; 175 | while (!closestCommonSuperview && firstViewSuperview) { 176 | if (secondViewSuperview == firstViewSuperview) { 177 | closestCommonSuperview = secondViewSuperview; 178 | } 179 | firstViewSuperview = firstViewSuperview.superview; 180 | } 181 | secondViewSuperview = secondViewSuperview.superview; 182 | } 183 | return closestCommonSuperview; 184 | } 185 | 186 | @end 187 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline; 36 | 37 | #endif 38 | 39 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 40 | 41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 49 | 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 53 | 54 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 55 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 56 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 57 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | 59 | #endif 60 | 61 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 62 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 63 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 64 | 65 | @end 66 | 67 | #define MAS_ATTR_FORWARD(attr) \ 68 | - (MASViewAttribute *)attr { \ 69 | return [self mas_##attr]; \ 70 | } 71 | 72 | @implementation MAS_VIEW (MASShorthandAdditions) 73 | 74 | MAS_ATTR_FORWARD(top); 75 | MAS_ATTR_FORWARD(left); 76 | MAS_ATTR_FORWARD(bottom); 77 | MAS_ATTR_FORWARD(right); 78 | MAS_ATTR_FORWARD(leading); 79 | MAS_ATTR_FORWARD(trailing); 80 | MAS_ATTR_FORWARD(width); 81 | MAS_ATTR_FORWARD(height); 82 | MAS_ATTR_FORWARD(centerX); 83 | MAS_ATTR_FORWARD(centerY); 84 | MAS_ATTR_FORWARD(baseline); 85 | 86 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 87 | 88 | MAS_ATTR_FORWARD(firstBaseline); 89 | MAS_ATTR_FORWARD(lastBaseline); 90 | 91 | #endif 92 | 93 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 94 | 95 | MAS_ATTR_FORWARD(leftMargin); 96 | MAS_ATTR_FORWARD(rightMargin); 97 | MAS_ATTR_FORWARD(topMargin); 98 | MAS_ATTR_FORWARD(bottomMargin); 99 | MAS_ATTR_FORWARD(leadingMargin); 100 | MAS_ATTR_FORWARD(trailingMargin); 101 | MAS_ATTR_FORWARD(centerXWithinMargins); 102 | MAS_ATTR_FORWARD(centerYWithinMargins); 103 | 104 | #endif 105 | 106 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 107 | 108 | MAS_ATTR_FORWARD(safeAreaLayoutGuideTop); 109 | MAS_ATTR_FORWARD(safeAreaLayoutGuideBottom); 110 | MAS_ATTR_FORWARD(safeAreaLayoutGuideLeft); 111 | MAS_ATTR_FORWARD(safeAreaLayoutGuideRight); 112 | 113 | #endif 114 | 115 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 116 | return [self mas_attribute]; 117 | } 118 | 119 | - (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 120 | return [self mas_makeConstraints:block]; 121 | } 122 | 123 | - (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 124 | return [self mas_updateConstraints:block]; 125 | } 126 | 127 | - (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 128 | return [self mas_remakeConstraints:block]; 129 | } 130 | 131 | @end 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /WMZTableView/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /WMZTableView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WMZTableView 4 | // 5 | // Created by wmz on 2018/10/22. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property(nonatomic,assign)NSInteger type; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /WMZTableView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WMZTableView 4 | // 5 | // Created by wmz on 2018/10/22. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "WMZTableView.h" 11 | @interface ViewController () 12 | @property(nonatomic,strong)NSMutableArray *dataArr; 13 | @property(nonatomic,strong)NSMutableArray *modelArr; 14 | @property(nonatomic,strong)WMZTableView *tableView; 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | //最简单的调用 24 | // GroupTableView() 25 | // .wAutoCell(YES) 26 | // .wMasonryConfig(self.view, ^(MASConstraintMaker *make) { 27 | // make.edges.mas_equalTo(0); 28 | // }, self.modelArr) 29 | // .wStart(); 30 | 31 | if (self.type!=0) { 32 | UIButton *leftbutton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]; 33 | [leftbutton setTitle:@"改变" forState:UIControlStateNormal]; 34 | [leftbutton setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 35 | [leftbutton addTarget:self action:@selector(add) forControlEvents:UIControlEventTouchUpInside]; 36 | UIBarButtonItem*item = [[UIBarButtonItem alloc]initWithCustomView:leftbutton]; 37 | self.navigationItem.rightBarButtonItem = item; 38 | } 39 | 40 | 41 | 42 | 43 | if (_type==0) { 44 | WMZWeakSelf 45 | self.tableView = GroupTableView() 46 | .wDealCell(^UITableViewCell *(NSIndexPath *indexPath, UITableView *tableView,id model) { 47 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])]; 48 | if (!cell) { 49 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([UITableViewCell class])]; 50 | } 51 | cell.textLabel.text = model; 52 | return cell; 53 | }).wMasonryConfig(self.view, ^(MASConstraintMaker *make) { 54 | make.edges.mas_equalTo(0); 55 | }, self.dataArr) 56 | .wDidSelect(^(NSIndexPath *indexPath, UITableView *tableView,id model) { 57 | ViewController *VC = [ViewController new]; 58 | VC.type = 1; 59 | [weakSelf.navigationController pushViewController:VC animated:YES]; 60 | }) 61 | .wStart(); 62 | 63 | 64 | }else{ 65 | 66 | self.tableView = GroupTableView() 67 | .wAutoCell(YES) 68 | .wMasonryConfig(self.view, ^(MASConstraintMaker *make) { 69 | make.edges.mas_equalTo(0); 70 | }, self.modelArr) 71 | // .wCellAnaiml(YES) 72 | // .wCellHeight(^NSInteger(NSIndexPath *indexPath, UITableView *tableView) { 73 | // return indexPath.row == 0 ? 200:UITableViewAutomaticDimension; 74 | // }) 75 | // .wCellFootHeight(^NSInteger(NSInteger section, UITableView *tableView) { 76 | // return 50; 77 | // }) 78 | // .wCellFootView(^UIView *(NSInteger section, UITableView *tableView) { 79 | // UIView *view = [UIView new]; 80 | // view.backgroundColor = [UIColor yellowColor]; 81 | // return view; 82 | // }) 83 | // .wCellHeadHeight(^NSInteger(NSInteger section, UITableView *tableView) { 84 | // return 50; 85 | // }) 86 | // .wCellHeadView(^UIView *(NSInteger section, UITableView *tableView) { 87 | // UIView *view = [UIView new]; 88 | // view.backgroundColor = [UIColor redColor]; 89 | // return view; 90 | // }) 91 | // .wSection(YES) 92 | .wOtherDelegate(self) 93 | .wStart(); 94 | 95 | 96 | } 97 | 98 | } 99 | 100 | 101 | 102 | - (void)add{ 103 | 104 | wBaseModel *model1 = [wBaseModel new]; 105 | model1.cellName = @"NornalCell"; 106 | model1.labelName = @"我是增加的文本1"; 107 | // 108 | wBaseModel *model2 = [wBaseModel new]; 109 | model2.cellName = @"NornalCellOne"; 110 | model2.labelName = @"我是增加的文本和图片"; 111 | model2.imageName = @"8.jpg"; 112 | // 113 | [self.modelArr removeObjectAtIndex:0]; 114 | [self.modelArr addObject:model1]; 115 | [self.modelArr removeObjectAtIndex:0]; 116 | [self.modelArr removeObjectAtIndex:0]; 117 | [self.modelArr insertObject:model1 atIndex:1]; 118 | [self.modelArr addObject:model1]; 119 | [self.modelArr addObject:model2]; 120 | ////// 121 | wBaseModel *model = self.modelArr[0]; 122 | model.cellName = @"NornalCell"; 123 | model.labelName = @"我是改变的文本"; 124 | 125 | 126 | self.tableView.wUpdateData(self.modelArr); 127 | 128 | } 129 | 130 | 131 | - (NSMutableArray *)dataArr{ 132 | if (!_dataArr) { 133 | _dataArr = [NSMutableArray arrayWithArray:@[@"cell1",@"cell2",@"cell3",@"cell4",@"cell5",@"cell6",@"cell7",@"cell8",@"cell9",@"cell10"]]; 134 | } 135 | return _dataArr; 136 | } 137 | 138 | - (NSMutableArray *)modelArr{ 139 | if (!_modelArr) { 140 | _modelArr = [NSMutableArray new]; 141 | 142 | int x = arc4random() % 30+10; 143 | x = 5; 144 | int x1 = arc4random() % 3+1; 145 | int x2 = arc4random() % 6+4; 146 | for (int i = 0; i 10 | #import "Masonry.h" 11 | 12 | 13 | #define WMZWeakSelf __weak typeof(self) weakSelf = self; 14 | 15 | #define WMZStrongSelf __strong typeof(self) strongSelf = self; 16 | 17 | @protocol WMZTableViewDelegate 18 | 19 | 20 | @optional //非必实现的方法 21 | 22 | /* 23 | * 头视图标题 如需调用此方法则tableView的头视图需要设为nil 才能生效 24 | */ 25 | - (NSString*)WMZTableViewTitleForFooterInSection:(NSInteger)section; 26 | 27 | /* 28 | * 尾视图标题 如需调用此方法则tableView的头视图需要设为nil 才能生效 29 | */ 30 | - (NSString*)WMZTableViewTitleForHeaderInSection:(NSInteger)section; 31 | 32 | /* 33 | * 设置删除/添加的样式 34 | */ 35 | -(UITableViewCellEditingStyle)WMZTableViewEditingStyleForRowAtIndexPath:(NSIndexPath *)indexPath; 36 | 37 | /* 38 | * 设置删除/添加的样式的显示内容 39 | */ 40 | -(NSString *)WMZTableViewTitleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath; 41 | 42 | /* 43 | * 删除/添加的样式的点击方法 44 | */ 45 | - (void)WMZTableViewCommitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath; 46 | 47 | /* 48 | * cell将显示的方法 49 | */ 50 | - (void)WMZTableViewWillDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; 51 | 52 | /* 53 | * cell开始编辑的方法 54 | */ 55 | - (void)WMZTableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath; 56 | 57 | /* 58 | * cell结束编辑的方法 59 | */ 60 | - (void)WMZTableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath; 61 | 62 | /* 63 | * 滑动 64 | */ 65 | - (void)WMZScrollViewDidScroll:(UIScrollView *)scrollView; 66 | 67 | /* 68 | *滑动多图标 69 | */ 70 | - (NSArray *)WMZTableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath; 71 | 72 | @end 73 | 74 | 75 | 76 | 77 | 78 | 79 | /* 80 | * cell的block 81 | */ 82 | typedef UITableViewCell* (^WMZCellCallBlock)(NSIndexPath *indexPath,UITableView* tableView,id model); 83 | 84 | /* 85 | * cell点击的block 86 | */ 87 | typedef void(^WMZSelectCallBlock)(NSIndexPath *indexPath,UITableView* tableView,id model); 88 | 89 | /* 90 | * cell高度的block 91 | */ 92 | typedef NSInteger (^WMZCellHeight)(NSIndexPath *indexPath,UITableView* tableView); 93 | 94 | 95 | /* 96 | * cell数量的block 97 | */ 98 | typedef NSInteger (^WMZCellCount)(NSInteger section,UITableView* tableView); 99 | 100 | /* 101 | * cell头视图高度的block 102 | */ 103 | typedef NSInteger (^WMZCellHeadHeight)(NSInteger section,UITableView* tableView); 104 | 105 | /* 106 | * cell尾视图高度的block 107 | */ 108 | typedef NSInteger (^WMZCellFootHeight)(NSInteger section,UITableView* tableView); 109 | 110 | /* 111 | * cell头视图的block 112 | */ 113 | typedef UIView * (^WMZCellHeadView)(NSInteger section,UITableView* tableView); 114 | 115 | /* 116 | * cell尾视图的block 117 | */ 118 | typedef UIView * (^WMZCellFootView)(NSInteger section,UITableView* tableView); 119 | 120 | 121 | /* 122 | * 布局 123 | */ 124 | typedef void(^WMZConstraint) (MASConstraintMaker *make); 125 | 126 | 127 | typedef enum : NSUInteger{ 128 | /* 129 | *默认是一个section,row = dataArr的数量 130 | */ 131 | CellTypeRows = 0, 132 | /* 133 | *默认是 的数量section数量是dataArr的数量 row对应子数组的数量 134 | *格式必须是 @[@[],@[],@[]] 135 | */ 136 | CellTypeSections = 1, 137 | }CellType; 138 | 139 | 140 | @interface WMZTableView : UITableView 141 | /* =========================================重要属性==============================================*/ 142 | /* =========================================重要属性==============================================*/ 143 | /* =========================================重要属性==============================================*/ 144 | 145 | /* 146 | * 初始化 Group样式 147 | */ 148 | WMZTableView * GroupTableView(void); 149 | 150 | /* 151 | * 初始化 Plain样式 152 | */ 153 | WMZTableView * PlainTableView(void); 154 | 155 | 156 | /* 157 | * 代理和dataSource开始 最后一步一定要调用这个属性 否则不生效 158 | */ 159 | @property(nonatomic,copy,readonly) WMZTableView *(^wStart)(void); 160 | 161 | /* 162 | * frame布局 163 | * 数据源 164 | */ 165 | @property(nonatomic,assign,readonly) WMZTableView *(^wFrameConfig)(UIView *wParentView,CGRect wFrame,NSMutableArray *myDataArr); 166 | 167 | /* 168 | * masonry布局 169 | * 数据源 170 | */ 171 | @property(nonatomic,assign,readonly) WMZTableView *(^wMasonryConfig)(UIView *wParentView,WMZConstraint wMasonry,NSMutableArray *myDataArr); 172 | 173 | /* 174 | * cell方法 175 | * 自定义外层自己传进来 176 | */ 177 | @property(nonatomic,copy,readonly) WMZTableView *(^wDealCell)(WMZCellCallBlock block); 178 | 179 | 180 | /* 181 | * cell点击 182 | */ 183 | @property(nonatomic,copy,readonly) WMZTableView *(^wDidSelect)(WMZSelectCallBlock block); 184 | 185 | 186 | 187 | /* 188 | * 更新数据 把改变完的数组传进来即可 自动局部刷新 189 | */ 190 | @property(nonatomic,strong,readonly) WMZTableView *(^wUpdateData)(NSMutableArray *changeData); 191 | 192 | 193 | /* 194 | * WMZ代理 其他的tableview的代理方法 195 | */ 196 | @property(nonatomic,weak,readonly) WMZTableView *(^wOtherDelegate)(id delegate); 197 | 198 | /* =========================================重要属性==============================================*/ 199 | /* =========================================重要属性==============================================*/ 200 | /* =========================================重要属性==============================================*/ 201 | 202 | 203 | 204 | 205 | /* =========================================拓展属性==============================================*/ 206 | /* =========================================拓展属性==============================================*/ 207 | /* =========================================拓展属性==============================================*/ 208 | 209 | 210 | /* 211 | * kvc写法 适合继承或直接使用wBaseModel 需要传cell对应class的名字 对组件化熟悉的可以调用 模型控制UI 212 | */ 213 | @property(nonatomic,assign,readonly) WMZTableView *(^wAutoCell)(BOOL autoCell); 214 | 215 | 216 | /* 217 | * 开启默认tableview配置 218 | */ 219 | @property(nonatomic,assign,readonly) WMZTableView *(^wConfig)(BOOL config); 220 | 221 | 222 | /* 223 | * wSection 是section 224 | 225 | *默认NO 226 | *默认是一个section,row = dataArr的数量 227 | 228 | *YES的时候 section数量是dataArr的数量 row对应子数组的数量 229 | *格式必须是 @[@[],@[],@[]] 230 | */ 231 | @property(nonatomic,assign,readonly) WMZTableView *(^wSection)(BOOL isSection); 232 | 233 | 234 | /* 235 | * 设置cell高度 236 | */ 237 | @property(nonatomic,copy,readonly) WMZTableView *(^wCellHeight)(WMZCellHeight block); 238 | 239 | /* 240 | * 设置cell头视图高度 241 | */ 242 | @property(nonatomic,copy,readonly) WMZTableView *(^wCellHeadHeight)(WMZCellHeadHeight block); 243 | 244 | /* 245 | * 设置cell尾视图高度 246 | */ 247 | @property(nonatomic,copy,readonly) WMZTableView *(^wCellFootHeight)(WMZCellFootHeight block); 248 | 249 | /* 250 | * 设置cell头视图样式 251 | */ 252 | @property(nonatomic,copy,readonly) WMZTableView *(^wCellHeadView)(WMZCellHeadView block); 253 | 254 | /* 255 | * 设置cell尾视图样式 256 | */ 257 | @property(nonatomic,copy,readonly) WMZTableView *(^wCellFootView)(WMZCellFootView block); 258 | 259 | 260 | /* 261 | * cell显示有动画 262 | */ 263 | @property(nonatomic,assign,readonly) WMZTableView *(^wCellAnaiml)(BOOL cellAnaiml); 264 | 265 | 266 | 267 | /* =========================================拓展属性==============================================*/ 268 | /* =========================================拓展属性==============================================*/ 269 | /* =========================================拓展属性==============================================*/ 270 | 271 | 272 | @end 273 | 274 | 275 | 276 | 277 | /* =========================================额外类==============================================*/ 278 | /* =========================================额外类==============================================*/ 279 | /* =========================================额外类==============================================*/ 280 | 281 | 282 | //自定义baseModel类 283 | @interface wBaseModel : NSObject 284 | 285 | @property(nonatomic,copy)NSString *cellName; 286 | 287 | @property(nonatomic,copy)NSString *imageName; 288 | 289 | @property(nonatomic,copy)NSString *labelName; 290 | 291 | @end 292 | 293 | //自定义baseCell 可以自己设置 294 | @interface wBaseCell : UITableViewCell 295 | 296 | @property(nonatomic,strong)wBaseModel *model; 297 | 298 | @end 299 | 300 | //自定义 cell 可以自己设置 301 | @interface NornalCell : wBaseCell 302 | 303 | @property(nonatomic,strong)UILabel *myLabel; 304 | 305 | @end 306 | 307 | @interface NornalCellOne : wBaseCell 308 | 309 | @property(nonatomic,strong)UILabel *myLabel; 310 | 311 | @property(nonatomic,strong)UIImageView *icon; 312 | 313 | @end 314 | 315 | @interface NornalCellSecond : wBaseCell 316 | 317 | @property(nonatomic,strong)UIImageView *icon; 318 | 319 | @end 320 | 321 | /* =========================================额外类==============================================*/ 322 | /* =========================================额外类==============================================*/ 323 | /* =========================================额外类==============================================*/ 324 | -------------------------------------------------------------------------------- /WMZTableView/WMZTableView/WMZTableView.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | // 4 | // WMZTableView.m 5 | // WMZTableView 6 | // 7 | // Created by wmz on 2018/10/22. 8 | // Copyright © 2018年 wmz. All rights reserved. 9 | // 10 | 11 | #define TICK NSDate *startTime = [NSDate date]; 12 | 13 | #define TOCK NSLog(@"Time: %f", -[startTime timeIntervalSinceNow]); 14 | 15 | #import "WMZTableView.h" 16 | #import 17 | @interface WMZTableView() 18 | 19 | @property (nonatomic, assign) BOOL scrolAnimal; //滚动有动画 20 | 21 | @property (nonatomic, assign) BOOL cellKVC ; //cell 是否是kvc写法 22 | 23 | @property (nonatomic, assign) BOOL config ; //tableview开启默认配置 24 | 25 | @property (nonatomic, strong) NSMutableArray *dataArr; //dataArr 深拷贝 26 | 27 | @property (nonatomic, strong) NSMutableArray *simpleDataArr; //dataArr 普通赋值 28 | 29 | @property (nonatomic, assign) BOOL isSection; //section 30 | 31 | @property (nonatomic, copy) WMZCellCallBlock cellBlock; //cell block 32 | 33 | @property (nonatomic, copy) WMZSelectCallBlock selectBlock; //cell 点击block 34 | 35 | @property (nonatomic, copy) WMZCellHeight cellHeightBlock; //cell高度 36 | 37 | @property (nonatomic, copy) WMZCellCount cellCountBlock; //cell数量 38 | 39 | @property (nonatomic, copy) WMZCellHeadHeight headHeightBlock; //cell头部高度 40 | 41 | @property (nonatomic, copy) WMZCellFootHeight footHeightBlock; //cell底部高度 42 | 43 | @property (nonatomic, copy) WMZCellHeadView headViewBlock; //cell头部视图 44 | 45 | @property (nonatomic, copy) WMZCellFootView footViewBlock; //cell底部视图 46 | 47 | @property(nonatomic,weak) id WMZdelegate; //代理方法 48 | 49 | @property(nonatomic,strong) NSMutableArray *cellNameArr; //注册的cell 50 | 51 | @property(nonatomic,strong) NSMutableArray *pushData; //传过来的数据 52 | 53 | @end 54 | @implementation WMZTableView 55 | 56 | /* 57 | * 初始化 58 | */ 59 | WMZTableView * GroupTableView(void){ 60 | 61 | return [WMZTableView shareGroup]; 62 | } 63 | 64 | /* 65 | * 初始化 66 | */ 67 | WMZTableView * PlainTableView(void){ 68 | return [WMZTableView sharePlain]; 69 | } 70 | 71 | +(instancetype)shareGroup{ 72 | WMZTableView *wmzTableView = [[WMZTableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped]; 73 | return wmzTableView; 74 | } 75 | 76 | +(instancetype)sharePlain{ 77 | WMZTableView *wmzTableView = [[WMZTableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain]; 78 | return wmzTableView; 79 | } 80 | 81 | /* 82 | * 代理和dataSource开始 最后一步一定要调用这个属性 否则不生效 83 | */ 84 | - (WMZTableView *(^)(void))wStart{ 85 | return ^WMZTableView*(){ 86 | if (self.config) { 87 | if (@available(iOS 11.0, *)) { 88 | self.estimatedSectionFooterHeight = 0.01; 89 | self.estimatedSectionHeaderHeight = 0.01; 90 | } 91 | self.rowHeight = UITableViewAutomaticDimension; 92 | self.estimatedRowHeight = 100.0f; 93 | self.separatorStyle = UITableViewCellSeparatorStyleNone; 94 | } 95 | [self getData:self.pushData]; 96 | if ([self reginerCell]) { 97 | self.delegate = self; 98 | self.dataSource = self; 99 | } 100 | 101 | return self; 102 | }; 103 | } 104 | 105 | 106 | - (WMZTableView *(^)( UIView *, CGRect, NSMutableArray *))wFrameConfig{ 107 | return ^WMZTableView*(UIView *wParent,CGRect wFrame,NSMutableArray* wDataArr){ 108 | 109 | self.pushData = [NSMutableArray arrayWithArray:wDataArr]; 110 | 111 | self.frame = wFrame; 112 | 113 | if (wParent) { 114 | [wParent addSubview:self]; 115 | } 116 | return self; 117 | }; 118 | } 119 | 120 | 121 | - (WMZTableView *(^)(UIView *, WMZConstraint, NSMutableArray *))wMasonryConfig{ 122 | return ^WMZTableView*(UIView *wParent,WMZConstraint wMasonry,NSMutableArray* wDataArr){ 123 | 124 | self.pushData = [NSMutableArray arrayWithArray:wDataArr]; 125 | 126 | if (wParent) { 127 | [wParent addSubview:self]; 128 | if (wMasonry) { 129 | [self mas_makeConstraints:wMasonry]; 130 | } 131 | } 132 | return self; 133 | }; 134 | } 135 | 136 | 137 | 138 | 139 | - (WMZTableView *(^)(NSMutableArray *))wUpdateData{ 140 | return ^WMZTableView*(NSMutableArray *changeData){ 141 | if(changeData){ 142 | if (self.isSection) { 143 | if (changeData.count == self.simpleDataArr.count) { 144 | for (int i = 0; i))wOtherDelegate{ 250 | return ^WMZTableView*(id wOtherDelegate){ 251 | if (wOtherDelegate) { 252 | self.WMZdelegate = wOtherDelegate; 253 | } 254 | return self; 255 | }; 256 | } 257 | 258 | - (WMZTableView *(^)(BOOL))wSection{ 259 | return ^WMZTableView*(BOOL wSection){ 260 | self.isSection = wSection; 261 | 262 | return self; 263 | }; 264 | } 265 | 266 | 267 | - (WMZTableView *(^)(BOOL))wCellAnaiml{ 268 | return ^WMZTableView*(BOOL wCellAnaiml){ 269 | self.scrolAnimal = wCellAnaiml; 270 | return self; 271 | }; 272 | } 273 | 274 | 275 | - (WMZTableView *(^)(BOOL))wAutoCell{ 276 | return ^WMZTableView*(BOOL wAutoCell){ 277 | self.cellKVC = wAutoCell; 278 | return self; 279 | }; 280 | } 281 | 282 | - (WMZTableView *(^)(BOOL))wConfig{ 283 | return ^WMZTableView*(BOOL wConfig){ 284 | self.config = wConfig; 285 | return self; 286 | }; 287 | } 288 | 289 | /* 290 | *赋值数据 291 | */ 292 | - (void)getData:(NSMutableArray*)data{ 293 | 294 | if (data) { 295 | //深拷贝 包括数组内的元素 296 | if (self.isSection) { 297 | self.dataArr = [NSMutableArray new]; 298 | self.simpleDataArr = [NSMutableArray new]; 299 | for (NSArray *copyArr in data) { 300 | [self.dataArr addObject:[[NSMutableArray alloc] initWithArray:[copyArr mutableCopy] copyItems:YES]]; 301 | } 302 | 303 | //深拷贝 数组内的元素不深拷贝 304 | for (NSArray *copyArr in data) { 305 | [self.simpleDataArr addObject:[copyArr mutableCopy]]; 306 | } 307 | 308 | }else{ 309 | self.dataArr = [[NSMutableArray alloc] initWithArray:data copyItems:YES]; 310 | //普通赋值 311 | self.simpleDataArr = [NSMutableArray arrayWithArray:data]; 312 | } 313 | 314 | 315 | } 316 | 317 | } 318 | 319 | /* 320 | *注册cell 321 | */ 322 | - (BOOL)reginerCell{ 323 | if (!self.cellKVC) return YES; 324 | 325 | self.cellNameArr = [NSMutableArray new]; 326 | 327 | if (self.isSection ) { 328 | for (NSArray *arr in self.dataArr) { 329 | if(![arr isKindOfClass:[NSArray class]]||![arr isKindOfClass:[NSMutableArray class]]){ 330 | NSLog(@"请输入正确的数据源 格式为@[@[],@[],@[]]"); 331 | return NO; 332 | } 333 | for (wBaseModel *model in arr) { 334 | if ([self.cellNameArr indexOfObject:model.cellName]!=NSNotFound) continue; 335 | if (model.cellName) [self.cellNameArr addObject:model.cellName]; 336 | } 337 | } 338 | 339 | }else{ 340 | for (wBaseModel *model in self.dataArr) { 341 | if(![model isKindOfClass:[wBaseModel class]]){ 342 | NSLog(@"请输入正确的数据源 格式为@[wBaseModel,wBaseModel,wBaseModel]"); 343 | return NO; 344 | } 345 | if ([self.cellNameArr indexOfObject:model.cellName]!=NSNotFound) continue; 346 | if (model.cellName) [self.cellNameArr addObject:model.cellName]; 347 | } 348 | } 349 | 350 | for (NSString *cellName in self.cellNameArr) { 351 | if (cellName) { 352 | Class cellClass = NSClassFromString(cellName); 353 | [self registerClass:[cellClass class] forCellReuseIdentifier:cellName]; 354 | } 355 | } 356 | 357 | return YES; 358 | } 359 | 360 | /* 361 | *对比改变后的数据源与原来的数据源 并刷新 row 362 | */ 363 | - (void)compareData:(NSMutableArray*)data beforeData:(NSMutableArray*)beforeData changeData:(NSMutableArray*)nornalData withSection:(NSInteger)section{ 364 | TICK 365 | //更新的块 366 | NSMutableArray *changePathArr = [NSMutableArray new]; 367 | //添加的块 368 | NSMutableArray *insertPathArr = [NSMutableArray new]; 369 | //删除的块 370 | NSMutableArray *deletePathArr = [NSMutableArray new]; 371 | 372 | //取出相同的 373 | NSMutableArray *sameArr = [NSMutableArray new]; 374 | //找出beforeData中有 data没有的 375 | NSMutableArray *differentArr = [NSMutableArray new]; 376 | //找出data中有 beforeData没有的 377 | NSMutableArray *addArr = [NSMutableArray new]; 378 | 379 | 380 | 381 | for (int i = 0; i0) { 416 | 417 | for (int i = 0; i< changeArr.count; i++) { 418 | NSDictionary *dic = changeArr[i]; 419 | id changeModel = dic[@"changeModel"]; 420 | 421 | NSInteger index = [dic[@"index"] integerValue]; 422 | //重新复制 423 | [nornalData replaceObjectAtIndex:index withObject:[changeModel copy]]; 424 | 425 | [self reSetCellName:[changeModel valueForKey:@"cellName"]]; 426 | 427 | NSIndexPath *path = [NSIndexPath indexPathForRow:index inSection:section]; 428 | [changePathArr addObject:path]; 429 | } 430 | 431 | 432 | if (changePathArr.count>0) { 433 | [self reloadRowsAtIndexPaths:[NSArray arrayWithArray:changePathArr] withRowAnimation:UITableViewRowAnimationNone]; 434 | } 435 | 436 | } 437 | 438 | if (differentArr.count>0) { 439 | //倒序删除 防止数组在删除的时候index发生改变 导致删除错误或崩溃 440 | for (int i = (int)differentArr.count-1; i>= 0; i--) { 441 | NSDictionary *dic = differentArr[i]; 442 | NSInteger index = [dic[@"index"] integerValue]; 443 | 444 | [nornalData removeObjectAtIndex:index]; 445 | 446 | NSIndexPath *path = [NSIndexPath indexPathForRow:index inSection:section]; 447 | [deletePathArr addObject:path]; 448 | } 449 | //局部删除 450 | if (deletePathArr.count>0) { 451 | [self deleteRowsAtIndexPaths:[NSArray arrayWithArray:deletePathArr] withRowAnimation:UITableViewRowAnimationNone]; 452 | } 453 | } 454 | 455 | if (addArr.count > 0) { 456 | for (int i = 0; i< addArr.count; i++) { 457 | NSDictionary *dic = addArr[i]; 458 | id changeModel = dic[@"model"]; 459 | NSInteger index = [dic[@"index"] integerValue]; 460 | if (nornalData.count>index) { 461 | [nornalData insertObject:[changeModel copy] atIndex:index]; 462 | }else{ 463 | [nornalData addObject:[changeModel copy]]; 464 | } 465 | 466 | [self reSetCellName:[changeModel valueForKey:@"cellName"]]; 467 | NSIndexPath *path = [NSIndexPath indexPathForRow:index inSection:section]; 468 | [insertPathArr addObject:path]; 469 | } 470 | 471 | 472 | //局部增加 473 | if (insertPathArr.count>0) { 474 | [self insertRowsAtIndexPaths:[NSArray arrayWithArray:insertPathArr] withRowAnimation:UITableViewRowAnimationNone]; 475 | } 476 | } 477 | 478 | TOCK 479 | 480 | } 481 | 482 | 483 | 484 | 485 | //注册未注册过的cellName 486 | - (void)reSetCellName:(NSString*)cellName{ 487 | if (cellName&&[cellName isKindOfClass:[NSString class]]) { 488 | if ([self.cellNameArr indexOfObject:cellName] == NSNotFound) { 489 | [self.cellNameArr addObject:cellName]; 490 | Class cellClass = NSClassFromString(cellName); 491 | [self registerClass:[cellClass class] forCellReuseIdentifier:cellName]; 492 | } 493 | }else{ 494 | NSLog(@"请输入正确的数据"); 495 | } 496 | } 497 | 498 | //对比model是否属性改变过 499 | -(NSMutableArray*)compareModelArr:(NSArray*)sameArr beforeData:(NSMutableArray*)nornalData{ 500 | NSMutableArray *changeArr = [NSMutableArray new]; 501 | if (sameArr.count == 0) { 502 | return changeArr; 503 | } 504 | for (int i = 0; i *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{ 701 | if (self.WMZdelegate && [self.WMZdelegate respondsToSelector:@selector(WMZTableView:editActionsForRowAtIndexPath:)]) { 702 | return [self.WMZdelegate WMZTableView:tableView editActionsForRowAtIndexPath:indexPath]; 703 | } 704 | return nil; 705 | } 706 | 707 | 708 | 709 | 710 | - (void)dealloc{ 711 | NSLog(@"view销毁"); 712 | // [self removeObserver:self forKeyPath:@"dataArr"]; 713 | } 714 | 715 | @end 716 | 717 | 718 | @implementation wBaseModel 719 | - (id)copyWithZone:(NSZone *)zone{ 720 | wBaseModel *model = [wBaseModel new]; 721 | model.cellName = _cellName; 722 | model.imageName = _imageName; 723 | model.labelName = _labelName; 724 | return model; 725 | } 726 | @end 727 | 728 | 729 | @implementation wBaseCell 730 | 731 | @end 732 | 733 | 734 | @implementation NornalCell 735 | 736 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 737 | 738 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 739 | 740 | [self.contentView addSubview:self.myLabel]; 741 | 742 | [self.myLabel mas_makeConstraints:^(MASConstraintMaker *make) { 743 | make.left.equalTo(self.contentView).offset(20); 744 | make.right.equalTo(self.contentView).offset(-20); 745 | make.top.equalTo(self.contentView).offset(10); 746 | make.bottom.equalTo(self.contentView).offset(-10); 747 | }]; 748 | } 749 | return self; 750 | } 751 | 752 | - (void)setModel:(wBaseModel *)model{ 753 | self.myLabel.text = model.labelName; 754 | } 755 | 756 | - (UILabel *)myLabel{ 757 | if (!_myLabel) { 758 | _myLabel = [UILabel new]; 759 | _myLabel.numberOfLines = 0; 760 | 761 | } 762 | return _myLabel; 763 | } 764 | 765 | @end 766 | 767 | @implementation NornalCellOne 768 | 769 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 770 | 771 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 772 | 773 | [self.contentView addSubview:self.myLabel]; 774 | [self.myLabel mas_makeConstraints:^(MASConstraintMaker *make) { 775 | make.left.equalTo(self.contentView).offset(20); 776 | make.right.equalTo(self.contentView).offset(-20); 777 | make.top.equalTo(self.contentView).offset(10); 778 | }]; 779 | 780 | [self.contentView addSubview:self.icon]; 781 | [self.icon mas_makeConstraints:^(MASConstraintMaker *make) { 782 | make.left.equalTo(self.contentView).offset(30); 783 | make.right.equalTo(self.contentView).offset(-30); 784 | make.top.equalTo(self.myLabel.mas_bottom).offset(10); 785 | make.bottom.equalTo(self.contentView).offset(-10); 786 | }]; 787 | } 788 | return self; 789 | } 790 | 791 | - (void)setModel:(wBaseModel *)model{ 792 | self.myLabel.text = model.labelName; 793 | self.icon.image = [UIImage imageNamed:model.imageName]; 794 | } 795 | 796 | - (UILabel *)myLabel{ 797 | if (!_myLabel) { 798 | _myLabel = [UILabel new]; 799 | _myLabel.numberOfLines = 0; 800 | 801 | } 802 | return _myLabel; 803 | } 804 | 805 | - (UIImageView *)icon{ 806 | if (!_icon) { 807 | _icon = [UIImageView new]; 808 | _icon.image = [UIImage imageNamed:@"6.jpg"]; 809 | } 810 | return _icon; 811 | } 812 | 813 | 814 | @end 815 | 816 | @implementation NornalCellSecond 817 | 818 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 819 | 820 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 821 | 822 | [self.contentView addSubview:self.icon]; 823 | [self.icon mas_makeConstraints:^(MASConstraintMaker *make) { 824 | make.left.equalTo(self.contentView).offset(80); 825 | make.right.equalTo(self.contentView).offset(-80); 826 | make.top.equalTo(self.contentView).offset(20); 827 | make.bottom.equalTo(self.contentView).offset(-20); 828 | }]; 829 | } 830 | return self; 831 | } 832 | 833 | - (UIImageView *)icon{ 834 | if (!_icon) { 835 | _icon = [UIImageView new]; 836 | _icon.image = [UIImage imageNamed:@"6.jpg"]; 837 | } 838 | return _icon; 839 | } 840 | 841 | - (void)setModel:(wBaseModel *)model{ 842 | self.icon.image = [UIImage imageNamed:model.imageName]; 843 | } 844 | 845 | @end 846 | -------------------------------------------------------------------------------- /WMZTableView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WMZTableView 4 | // 5 | // Created by wmz on 2018/10/22. 6 | // Copyright © 2018年 wmz. 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 | -------------------------------------------------------------------------------- /WMZTableView/source/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/0.jpg -------------------------------------------------------------------------------- /WMZTableView/source/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/1.jpg -------------------------------------------------------------------------------- /WMZTableView/source/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/2.jpg -------------------------------------------------------------------------------- /WMZTableView/source/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/3.jpg -------------------------------------------------------------------------------- /WMZTableView/source/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/4.jpg -------------------------------------------------------------------------------- /WMZTableView/source/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/5.jpg -------------------------------------------------------------------------------- /WMZTableView/source/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/6.jpg -------------------------------------------------------------------------------- /WMZTableView/source/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/7.jpg -------------------------------------------------------------------------------- /WMZTableView/source/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/8.jpg -------------------------------------------------------------------------------- /WMZTableView/source/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZTableView/00d1a92c3694e54cb950df059e5885e84c279b00/WMZTableView/source/9.jpg -------------------------------------------------------------------------------- /WMZTableViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WMZTableViewTests/WMZTableViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZTableViewTests.m 3 | // WMZTableViewTests 4 | // 5 | // Created by wmz on 2018/10/22. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WMZTableViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WMZTableViewTests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | } 20 | 21 | - (void)tearDown { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | - (void)testExample { 26 | // This is an example of a functional test case. 27 | // Use XCTAssert and related functions to verify your tests produce the correct results. 28 | } 29 | 30 | - (void)testPerformanceExample { 31 | // This is an example of a performance test case. 32 | [self measureBlock:^{ 33 | // Put the code you want to measure the time of here. 34 | }]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /WMZTableViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WMZTableViewUITests/WMZTableViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZTableViewUITests.m 3 | // WMZTableViewUITests 4 | // 5 | // Created by wmz on 2018/10/22. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WMZTableViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WMZTableViewUITests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | 20 | // In UI tests it is usually best to stop immediately when a failure occurs. 21 | self.continueAfterFailure = NO; 22 | 23 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 24 | [[[XCUIApplication alloc] init] launch]; 25 | 26 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 27 | } 28 | 29 | - (void)tearDown { 30 | // Put teardown code here. This method is called after the invocation of each test method in the class. 31 | } 32 | 33 | - (void)testExample { 34 | // Use recording to get started writing UI tests. 35 | // Use XCTAssert and related functions to verify your tests produce the correct results. 36 | } 37 | 38 | @end 39 | --------------------------------------------------------------------------------