├── LICENSE ├── QJSlideView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── justin.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── xcdebugger │ │ └── Expressions.xcexplist └── xcuserdata │ └── justin.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── QJSlideView.xcscheme │ └── xcschememanagement.plist ├── QJSlideView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Helper.h ├── Helper.m ├── Info.plist ├── Masonry │ ├── LICENSE │ ├── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── MASConstraintMaker.m │ │ ├── MASLayoutConstraint.h │ │ ├── MASLayoutConstraint.m │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewConstraint.h │ │ ├── MASViewConstraint.m │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASAdditions.m │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── View+MASAdditions.h │ │ ├── View+MASAdditions.m │ │ ├── View+MASShorthandAdditions.h │ │ ├── ViewController+MASAdditions.h │ │ └── ViewController+MASAdditions.m │ └── README.md ├── NavigationViewController.h ├── NavigationViewController.m ├── QJBigScrollView.h ├── QJBigScrollView.m ├── QJSlideButtonView.h ├── QJSlideButtonView.m ├── QJsampleView.h ├── QJsampleView.m ├── ViewController.h ├── ViewController.m └── main.m ├── QJSlideViewTests ├── Info.plist └── QJSlideViewTests.m ├── QJSlideViewUITests ├── Info.plist └── QJSlideViewUITests.m └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 justinAce 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /QJSlideView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D0BCF6421C9141110044448C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6411C9141110044448C /* main.m */; }; 11 | D0BCF6451C9141110044448C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6441C9141110044448C /* AppDelegate.m */; }; 12 | D0BCF6481C9141110044448C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6471C9141110044448C /* ViewController.m */; }; 13 | D0BCF64B1C9141110044448C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D0BCF6491C9141110044448C /* Main.storyboard */; }; 14 | D0BCF64D1C9141110044448C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D0BCF64C1C9141110044448C /* Assets.xcassets */; }; 15 | D0BCF6501C9141110044448C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D0BCF64E1C9141110044448C /* LaunchScreen.storyboard */; }; 16 | D0BCF65B1C9141110044448C /* QJSlideViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF65A1C9141110044448C /* QJSlideViewTests.m */; }; 17 | D0BCF6661C9141110044448C /* QJSlideViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6651C9141110044448C /* QJSlideViewUITests.m */; }; 18 | D0BCF6761C9142700044448C /* QJSlideButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6751C9142700044448C /* QJSlideButtonView.m */; }; 19 | D0BCF6941C91467F0044448C /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = D0BCF6781C91467F0044448C /* LICENSE */; }; 20 | D0BCF6951C91467F0044448C /* MASCompositeConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF67B1C91467F0044448C /* MASCompositeConstraint.m */; }; 21 | D0BCF6961C91467F0044448C /* MASConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF67E1C91467F0044448C /* MASConstraint.m */; }; 22 | D0BCF6971C91467F0044448C /* MASConstraintMaker.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6801C91467F0044448C /* MASConstraintMaker.m */; }; 23 | D0BCF6981C91467F0044448C /* MASLayoutConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6821C91467F0044448C /* MASLayoutConstraint.m */; }; 24 | D0BCF6991C91467F0044448C /* MASViewAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6861C91467F0044448C /* MASViewAttribute.m */; }; 25 | D0BCF69A1C91467F0044448C /* MASViewConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6881C91467F0044448C /* MASViewConstraint.m */; }; 26 | D0BCF69B1C91467F0044448C /* NSArray+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF68A1C91467F0044448C /* NSArray+MASAdditions.m */; }; 27 | D0BCF69C1C91467F0044448C /* NSLayoutConstraint+MASDebugAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF68D1C91467F0044448C /* NSLayoutConstraint+MASDebugAdditions.m */; }; 28 | D0BCF69D1C91467F0044448C /* View+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF68F1C91467F0044448C /* View+MASAdditions.m */; }; 29 | D0BCF69E1C91467F0044448C /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6921C91467F0044448C /* ViewController+MASAdditions.m */; }; 30 | D0BCF69F1C91467F0044448C /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6931C91467F0044448C /* README.md */; }; 31 | D0BCF6A21C9154650044448C /* NavigationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BCF6A11C9154650044448C /* NavigationViewController.m */; }; 32 | D0FFAA661C91AE1E006E5FCD /* QJBigScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FFAA651C91AE1E006E5FCD /* QJBigScrollView.m */; }; 33 | D0FFAA6C1C93F5BD006E5FCD /* QJsampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FFAA6B1C93F5BD006E5FCD /* QJsampleView.m */; }; 34 | D0FFAA6F1C94317D006E5FCD /* Helper.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FFAA6E1C94317D006E5FCD /* Helper.m */; }; 35 | /* End PBXBuildFile section */ 36 | 37 | /* Begin PBXContainerItemProxy section */ 38 | D0BCF6571C9141110044448C /* PBXContainerItemProxy */ = { 39 | isa = PBXContainerItemProxy; 40 | containerPortal = D0BCF6351C9141110044448C /* Project object */; 41 | proxyType = 1; 42 | remoteGlobalIDString = D0BCF63C1C9141110044448C; 43 | remoteInfo = QJSlideView; 44 | }; 45 | D0BCF6621C9141110044448C /* PBXContainerItemProxy */ = { 46 | isa = PBXContainerItemProxy; 47 | containerPortal = D0BCF6351C9141110044448C /* Project object */; 48 | proxyType = 1; 49 | remoteGlobalIDString = D0BCF63C1C9141110044448C; 50 | remoteInfo = QJSlideView; 51 | }; 52 | /* End PBXContainerItemProxy section */ 53 | 54 | /* Begin PBXFileReference section */ 55 | D0BCF63D1C9141110044448C /* QJSlideView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QJSlideView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | D0BCF6411C9141110044448C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 57 | D0BCF6431C9141110044448C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 58 | D0BCF6441C9141110044448C /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 59 | D0BCF6461C9141110044448C /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 60 | D0BCF6471C9141110044448C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 61 | D0BCF64A1C9141110044448C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 62 | D0BCF64C1C9141110044448C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 63 | D0BCF64F1C9141110044448C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 64 | D0BCF6511C9141110044448C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 65 | D0BCF6561C9141110044448C /* QJSlideViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QJSlideViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | D0BCF65A1C9141110044448C /* QJSlideViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QJSlideViewTests.m; sourceTree = ""; }; 67 | D0BCF65C1C9141110044448C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 68 | D0BCF6611C9141110044448C /* QJSlideViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QJSlideViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 69 | D0BCF6651C9141110044448C /* QJSlideViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QJSlideViewUITests.m; sourceTree = ""; }; 70 | D0BCF6671C9141110044448C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 71 | D0BCF6741C9142700044448C /* QJSlideButtonView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QJSlideButtonView.h; sourceTree = ""; }; 72 | D0BCF6751C9142700044448C /* QJSlideButtonView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QJSlideButtonView.m; sourceTree = ""; }; 73 | D0BCF6781C91467F0044448C /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 74 | D0BCF67A1C91467F0044448C /* MASCompositeConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASCompositeConstraint.h; sourceTree = ""; }; 75 | D0BCF67B1C91467F0044448C /* MASCompositeConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASCompositeConstraint.m; sourceTree = ""; }; 76 | D0BCF67C1C91467F0044448C /* MASConstraint+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASConstraint+Private.h"; sourceTree = ""; }; 77 | D0BCF67D1C91467F0044448C /* MASConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraint.h; sourceTree = ""; }; 78 | D0BCF67E1C91467F0044448C /* MASConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraint.m; sourceTree = ""; }; 79 | D0BCF67F1C91467F0044448C /* MASConstraintMaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraintMaker.h; sourceTree = ""; }; 80 | D0BCF6801C91467F0044448C /* MASConstraintMaker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraintMaker.m; sourceTree = ""; }; 81 | D0BCF6811C91467F0044448C /* MASLayoutConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASLayoutConstraint.h; sourceTree = ""; }; 82 | D0BCF6821C91467F0044448C /* MASLayoutConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASLayoutConstraint.m; sourceTree = ""; }; 83 | D0BCF6831C91467F0044448C /* Masonry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Masonry.h; sourceTree = ""; }; 84 | D0BCF6841C91467F0044448C /* MASUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASUtilities.h; sourceTree = ""; }; 85 | D0BCF6851C91467F0044448C /* MASViewAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewAttribute.h; sourceTree = ""; }; 86 | D0BCF6861C91467F0044448C /* MASViewAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewAttribute.m; sourceTree = ""; }; 87 | D0BCF6871C91467F0044448C /* MASViewConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewConstraint.h; sourceTree = ""; }; 88 | D0BCF6881C91467F0044448C /* MASViewConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewConstraint.m; sourceTree = ""; }; 89 | D0BCF6891C91467F0044448C /* NSArray+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASAdditions.h"; sourceTree = ""; }; 90 | D0BCF68A1C91467F0044448C /* NSArray+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+MASAdditions.m"; sourceTree = ""; }; 91 | D0BCF68B1C91467F0044448C /* NSArray+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASShorthandAdditions.h"; sourceTree = ""; }; 92 | D0BCF68C1C91467F0044448C /* NSLayoutConstraint+MASDebugAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSLayoutConstraint+MASDebugAdditions.h"; sourceTree = ""; }; 93 | D0BCF68D1C91467F0044448C /* NSLayoutConstraint+MASDebugAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+MASDebugAdditions.m"; sourceTree = ""; }; 94 | D0BCF68E1C91467F0044448C /* View+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASAdditions.h"; sourceTree = ""; }; 95 | D0BCF68F1C91467F0044448C /* View+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "View+MASAdditions.m"; sourceTree = ""; }; 96 | D0BCF6901C91467F0044448C /* View+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASShorthandAdditions.h"; sourceTree = ""; }; 97 | D0BCF6911C91467F0044448C /* ViewController+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ViewController+MASAdditions.h"; sourceTree = ""; }; 98 | D0BCF6921C91467F0044448C /* ViewController+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ViewController+MASAdditions.m"; sourceTree = ""; }; 99 | D0BCF6931C91467F0044448C /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 100 | D0BCF6A01C9154650044448C /* NavigationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationViewController.h; sourceTree = ""; }; 101 | D0BCF6A11C9154650044448C /* NavigationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationViewController.m; sourceTree = ""; }; 102 | D0FFAA641C91AE1E006E5FCD /* QJBigScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QJBigScrollView.h; sourceTree = ""; }; 103 | D0FFAA651C91AE1E006E5FCD /* QJBigScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QJBigScrollView.m; sourceTree = ""; }; 104 | D0FFAA6A1C93F5BD006E5FCD /* QJsampleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QJsampleView.h; sourceTree = ""; }; 105 | D0FFAA6B1C93F5BD006E5FCD /* QJsampleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QJsampleView.m; sourceTree = ""; }; 106 | D0FFAA6D1C94317D006E5FCD /* Helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Helper.h; sourceTree = ""; }; 107 | D0FFAA6E1C94317D006E5FCD /* Helper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Helper.m; sourceTree = ""; }; 108 | /* End PBXFileReference section */ 109 | 110 | /* Begin PBXFrameworksBuildPhase section */ 111 | D0BCF63A1C9141110044448C /* Frameworks */ = { 112 | isa = PBXFrameworksBuildPhase; 113 | buildActionMask = 2147483647; 114 | files = ( 115 | ); 116 | runOnlyForDeploymentPostprocessing = 0; 117 | }; 118 | D0BCF6531C9141110044448C /* Frameworks */ = { 119 | isa = PBXFrameworksBuildPhase; 120 | buildActionMask = 2147483647; 121 | files = ( 122 | ); 123 | runOnlyForDeploymentPostprocessing = 0; 124 | }; 125 | D0BCF65E1C9141110044448C /* Frameworks */ = { 126 | isa = PBXFrameworksBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | ); 130 | runOnlyForDeploymentPostprocessing = 0; 131 | }; 132 | /* End PBXFrameworksBuildPhase section */ 133 | 134 | /* Begin PBXGroup section */ 135 | D0BCF6341C9141110044448C = { 136 | isa = PBXGroup; 137 | children = ( 138 | D0BCF63F1C9141110044448C /* QJSlideView */, 139 | D0BCF6591C9141110044448C /* QJSlideViewTests */, 140 | D0BCF6641C9141110044448C /* QJSlideViewUITests */, 141 | D0BCF63E1C9141110044448C /* Products */, 142 | ); 143 | sourceTree = ""; 144 | }; 145 | D0BCF63E1C9141110044448C /* Products */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | D0BCF63D1C9141110044448C /* QJSlideView.app */, 149 | D0BCF6561C9141110044448C /* QJSlideViewTests.xctest */, 150 | D0BCF6611C9141110044448C /* QJSlideViewUITests.xctest */, 151 | ); 152 | name = Products; 153 | sourceTree = ""; 154 | }; 155 | D0BCF63F1C9141110044448C /* QJSlideView */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | D0BCF6731C91413B0044448C /* QjSlideView */, 159 | D0BCF6431C9141110044448C /* AppDelegate.h */, 160 | D0BCF6441C9141110044448C /* AppDelegate.m */, 161 | D0BCF6A01C9154650044448C /* NavigationViewController.h */, 162 | D0BCF6A11C9154650044448C /* NavigationViewController.m */, 163 | D0BCF6461C9141110044448C /* ViewController.h */, 164 | D0BCF6471C9141110044448C /* ViewController.m */, 165 | D0BCF6491C9141110044448C /* Main.storyboard */, 166 | D0BCF64C1C9141110044448C /* Assets.xcassets */, 167 | D0BCF64E1C9141110044448C /* LaunchScreen.storyboard */, 168 | D0BCF6511C9141110044448C /* Info.plist */, 169 | D0BCF6401C9141110044448C /* Supporting Files */, 170 | ); 171 | path = QJSlideView; 172 | sourceTree = ""; 173 | }; 174 | D0BCF6401C9141110044448C /* Supporting Files */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | D0BCF6411C9141110044448C /* main.m */, 178 | ); 179 | name = "Supporting Files"; 180 | sourceTree = ""; 181 | }; 182 | D0BCF6591C9141110044448C /* QJSlideViewTests */ = { 183 | isa = PBXGroup; 184 | children = ( 185 | D0BCF65A1C9141110044448C /* QJSlideViewTests.m */, 186 | D0BCF65C1C9141110044448C /* Info.plist */, 187 | ); 188 | path = QJSlideViewTests; 189 | sourceTree = ""; 190 | }; 191 | D0BCF6641C9141110044448C /* QJSlideViewUITests */ = { 192 | isa = PBXGroup; 193 | children = ( 194 | D0BCF6651C9141110044448C /* QJSlideViewUITests.m */, 195 | D0BCF6671C9141110044448C /* Info.plist */, 196 | ); 197 | path = QJSlideViewUITests; 198 | sourceTree = ""; 199 | }; 200 | D0BCF6731C91413B0044448C /* QjSlideView */ = { 201 | isa = PBXGroup; 202 | children = ( 203 | D0BCF6771C91467F0044448C /* Masonry */, 204 | D0BCF6741C9142700044448C /* QJSlideButtonView.h */, 205 | D0BCF6751C9142700044448C /* QJSlideButtonView.m */, 206 | D0FFAA641C91AE1E006E5FCD /* QJBigScrollView.h */, 207 | D0FFAA651C91AE1E006E5FCD /* QJBigScrollView.m */, 208 | D0FFAA6A1C93F5BD006E5FCD /* QJsampleView.h */, 209 | D0FFAA6B1C93F5BD006E5FCD /* QJsampleView.m */, 210 | D0FFAA6D1C94317D006E5FCD /* Helper.h */, 211 | D0FFAA6E1C94317D006E5FCD /* Helper.m */, 212 | ); 213 | name = QjSlideView; 214 | sourceTree = ""; 215 | }; 216 | D0BCF6771C91467F0044448C /* Masonry */ = { 217 | isa = PBXGroup; 218 | children = ( 219 | D0BCF6781C91467F0044448C /* LICENSE */, 220 | D0BCF6791C91467F0044448C /* Masonry */, 221 | D0BCF6931C91467F0044448C /* README.md */, 222 | ); 223 | path = Masonry; 224 | sourceTree = ""; 225 | }; 226 | D0BCF6791C91467F0044448C /* Masonry */ = { 227 | isa = PBXGroup; 228 | children = ( 229 | D0BCF67A1C91467F0044448C /* MASCompositeConstraint.h */, 230 | D0BCF67B1C91467F0044448C /* MASCompositeConstraint.m */, 231 | D0BCF67C1C91467F0044448C /* MASConstraint+Private.h */, 232 | D0BCF67D1C91467F0044448C /* MASConstraint.h */, 233 | D0BCF67E1C91467F0044448C /* MASConstraint.m */, 234 | D0BCF67F1C91467F0044448C /* MASConstraintMaker.h */, 235 | D0BCF6801C91467F0044448C /* MASConstraintMaker.m */, 236 | D0BCF6811C91467F0044448C /* MASLayoutConstraint.h */, 237 | D0BCF6821C91467F0044448C /* MASLayoutConstraint.m */, 238 | D0BCF6831C91467F0044448C /* Masonry.h */, 239 | D0BCF6841C91467F0044448C /* MASUtilities.h */, 240 | D0BCF6851C91467F0044448C /* MASViewAttribute.h */, 241 | D0BCF6861C91467F0044448C /* MASViewAttribute.m */, 242 | D0BCF6871C91467F0044448C /* MASViewConstraint.h */, 243 | D0BCF6881C91467F0044448C /* MASViewConstraint.m */, 244 | D0BCF6891C91467F0044448C /* NSArray+MASAdditions.h */, 245 | D0BCF68A1C91467F0044448C /* NSArray+MASAdditions.m */, 246 | D0BCF68B1C91467F0044448C /* NSArray+MASShorthandAdditions.h */, 247 | D0BCF68C1C91467F0044448C /* NSLayoutConstraint+MASDebugAdditions.h */, 248 | D0BCF68D1C91467F0044448C /* NSLayoutConstraint+MASDebugAdditions.m */, 249 | D0BCF68E1C91467F0044448C /* View+MASAdditions.h */, 250 | D0BCF68F1C91467F0044448C /* View+MASAdditions.m */, 251 | D0BCF6901C91467F0044448C /* View+MASShorthandAdditions.h */, 252 | D0BCF6911C91467F0044448C /* ViewController+MASAdditions.h */, 253 | D0BCF6921C91467F0044448C /* ViewController+MASAdditions.m */, 254 | ); 255 | path = Masonry; 256 | sourceTree = ""; 257 | }; 258 | /* End PBXGroup section */ 259 | 260 | /* Begin PBXNativeTarget section */ 261 | D0BCF63C1C9141110044448C /* QJSlideView */ = { 262 | isa = PBXNativeTarget; 263 | buildConfigurationList = D0BCF66A1C9141110044448C /* Build configuration list for PBXNativeTarget "QJSlideView" */; 264 | buildPhases = ( 265 | D0BCF6391C9141110044448C /* Sources */, 266 | D0BCF63A1C9141110044448C /* Frameworks */, 267 | D0BCF63B1C9141110044448C /* Resources */, 268 | ); 269 | buildRules = ( 270 | ); 271 | dependencies = ( 272 | ); 273 | name = QJSlideView; 274 | productName = QJSlideView; 275 | productReference = D0BCF63D1C9141110044448C /* QJSlideView.app */; 276 | productType = "com.apple.product-type.application"; 277 | }; 278 | D0BCF6551C9141110044448C /* QJSlideViewTests */ = { 279 | isa = PBXNativeTarget; 280 | buildConfigurationList = D0BCF66D1C9141110044448C /* Build configuration list for PBXNativeTarget "QJSlideViewTests" */; 281 | buildPhases = ( 282 | D0BCF6521C9141110044448C /* Sources */, 283 | D0BCF6531C9141110044448C /* Frameworks */, 284 | D0BCF6541C9141110044448C /* Resources */, 285 | ); 286 | buildRules = ( 287 | ); 288 | dependencies = ( 289 | D0BCF6581C9141110044448C /* PBXTargetDependency */, 290 | ); 291 | name = QJSlideViewTests; 292 | productName = QJSlideViewTests; 293 | productReference = D0BCF6561C9141110044448C /* QJSlideViewTests.xctest */; 294 | productType = "com.apple.product-type.bundle.unit-test"; 295 | }; 296 | D0BCF6601C9141110044448C /* QJSlideViewUITests */ = { 297 | isa = PBXNativeTarget; 298 | buildConfigurationList = D0BCF6701C9141110044448C /* Build configuration list for PBXNativeTarget "QJSlideViewUITests" */; 299 | buildPhases = ( 300 | D0BCF65D1C9141110044448C /* Sources */, 301 | D0BCF65E1C9141110044448C /* Frameworks */, 302 | D0BCF65F1C9141110044448C /* Resources */, 303 | ); 304 | buildRules = ( 305 | ); 306 | dependencies = ( 307 | D0BCF6631C9141110044448C /* PBXTargetDependency */, 308 | ); 309 | name = QJSlideViewUITests; 310 | productName = QJSlideViewUITests; 311 | productReference = D0BCF6611C9141110044448C /* QJSlideViewUITests.xctest */; 312 | productType = "com.apple.product-type.bundle.ui-testing"; 313 | }; 314 | /* End PBXNativeTarget section */ 315 | 316 | /* Begin PBXProject section */ 317 | D0BCF6351C9141110044448C /* Project object */ = { 318 | isa = PBXProject; 319 | attributes = { 320 | LastUpgradeCheck = 0720; 321 | ORGANIZATIONNAME = Justin; 322 | TargetAttributes = { 323 | D0BCF63C1C9141110044448C = { 324 | CreatedOnToolsVersion = 7.2; 325 | }; 326 | D0BCF6551C9141110044448C = { 327 | CreatedOnToolsVersion = 7.2; 328 | TestTargetID = D0BCF63C1C9141110044448C; 329 | }; 330 | D0BCF6601C9141110044448C = { 331 | CreatedOnToolsVersion = 7.2; 332 | TestTargetID = D0BCF63C1C9141110044448C; 333 | }; 334 | }; 335 | }; 336 | buildConfigurationList = D0BCF6381C9141110044448C /* Build configuration list for PBXProject "QJSlideView" */; 337 | compatibilityVersion = "Xcode 3.2"; 338 | developmentRegion = English; 339 | hasScannedForEncodings = 0; 340 | knownRegions = ( 341 | en, 342 | Base, 343 | ); 344 | mainGroup = D0BCF6341C9141110044448C; 345 | productRefGroup = D0BCF63E1C9141110044448C /* Products */; 346 | projectDirPath = ""; 347 | projectRoot = ""; 348 | targets = ( 349 | D0BCF63C1C9141110044448C /* QJSlideView */, 350 | D0BCF6551C9141110044448C /* QJSlideViewTests */, 351 | D0BCF6601C9141110044448C /* QJSlideViewUITests */, 352 | ); 353 | }; 354 | /* End PBXProject section */ 355 | 356 | /* Begin PBXResourcesBuildPhase section */ 357 | D0BCF63B1C9141110044448C /* Resources */ = { 358 | isa = PBXResourcesBuildPhase; 359 | buildActionMask = 2147483647; 360 | files = ( 361 | D0BCF6501C9141110044448C /* LaunchScreen.storyboard in Resources */, 362 | D0BCF64D1C9141110044448C /* Assets.xcassets in Resources */, 363 | D0BCF6941C91467F0044448C /* LICENSE in Resources */, 364 | D0BCF64B1C9141110044448C /* Main.storyboard in Resources */, 365 | ); 366 | runOnlyForDeploymentPostprocessing = 0; 367 | }; 368 | D0BCF6541C9141110044448C /* Resources */ = { 369 | isa = PBXResourcesBuildPhase; 370 | buildActionMask = 2147483647; 371 | files = ( 372 | ); 373 | runOnlyForDeploymentPostprocessing = 0; 374 | }; 375 | D0BCF65F1C9141110044448C /* Resources */ = { 376 | isa = PBXResourcesBuildPhase; 377 | buildActionMask = 2147483647; 378 | files = ( 379 | ); 380 | runOnlyForDeploymentPostprocessing = 0; 381 | }; 382 | /* End PBXResourcesBuildPhase section */ 383 | 384 | /* Begin PBXSourcesBuildPhase section */ 385 | D0BCF6391C9141110044448C /* Sources */ = { 386 | isa = PBXSourcesBuildPhase; 387 | buildActionMask = 2147483647; 388 | files = ( 389 | D0BCF6971C91467F0044448C /* MASConstraintMaker.m in Sources */, 390 | D0BCF6481C9141110044448C /* ViewController.m in Sources */, 391 | D0BCF6761C9142700044448C /* QJSlideButtonView.m in Sources */, 392 | D0FFAA6C1C93F5BD006E5FCD /* QJsampleView.m in Sources */, 393 | D0BCF6961C91467F0044448C /* MASConstraint.m in Sources */, 394 | D0BCF6A21C9154650044448C /* NavigationViewController.m in Sources */, 395 | D0BCF69E1C91467F0044448C /* ViewController+MASAdditions.m in Sources */, 396 | D0BCF6981C91467F0044448C /* MASLayoutConstraint.m in Sources */, 397 | D0BCF69B1C91467F0044448C /* NSArray+MASAdditions.m in Sources */, 398 | D0FFAA6F1C94317D006E5FCD /* Helper.m in Sources */, 399 | D0BCF69A1C91467F0044448C /* MASViewConstraint.m in Sources */, 400 | D0BCF6991C91467F0044448C /* MASViewAttribute.m in Sources */, 401 | D0BCF69D1C91467F0044448C /* View+MASAdditions.m in Sources */, 402 | D0BCF6451C9141110044448C /* AppDelegate.m in Sources */, 403 | D0BCF6421C9141110044448C /* main.m in Sources */, 404 | D0BCF69F1C91467F0044448C /* README.md in Sources */, 405 | D0FFAA661C91AE1E006E5FCD /* QJBigScrollView.m in Sources */, 406 | D0BCF6951C91467F0044448C /* MASCompositeConstraint.m in Sources */, 407 | D0BCF69C1C91467F0044448C /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, 408 | ); 409 | runOnlyForDeploymentPostprocessing = 0; 410 | }; 411 | D0BCF6521C9141110044448C /* Sources */ = { 412 | isa = PBXSourcesBuildPhase; 413 | buildActionMask = 2147483647; 414 | files = ( 415 | D0BCF65B1C9141110044448C /* QJSlideViewTests.m in Sources */, 416 | ); 417 | runOnlyForDeploymentPostprocessing = 0; 418 | }; 419 | D0BCF65D1C9141110044448C /* Sources */ = { 420 | isa = PBXSourcesBuildPhase; 421 | buildActionMask = 2147483647; 422 | files = ( 423 | D0BCF6661C9141110044448C /* QJSlideViewUITests.m in Sources */, 424 | ); 425 | runOnlyForDeploymentPostprocessing = 0; 426 | }; 427 | /* End PBXSourcesBuildPhase section */ 428 | 429 | /* Begin PBXTargetDependency section */ 430 | D0BCF6581C9141110044448C /* PBXTargetDependency */ = { 431 | isa = PBXTargetDependency; 432 | target = D0BCF63C1C9141110044448C /* QJSlideView */; 433 | targetProxy = D0BCF6571C9141110044448C /* PBXContainerItemProxy */; 434 | }; 435 | D0BCF6631C9141110044448C /* PBXTargetDependency */ = { 436 | isa = PBXTargetDependency; 437 | target = D0BCF63C1C9141110044448C /* QJSlideView */; 438 | targetProxy = D0BCF6621C9141110044448C /* PBXContainerItemProxy */; 439 | }; 440 | /* End PBXTargetDependency section */ 441 | 442 | /* Begin PBXVariantGroup section */ 443 | D0BCF6491C9141110044448C /* Main.storyboard */ = { 444 | isa = PBXVariantGroup; 445 | children = ( 446 | D0BCF64A1C9141110044448C /* Base */, 447 | ); 448 | name = Main.storyboard; 449 | sourceTree = ""; 450 | }; 451 | D0BCF64E1C9141110044448C /* LaunchScreen.storyboard */ = { 452 | isa = PBXVariantGroup; 453 | children = ( 454 | D0BCF64F1C9141110044448C /* Base */, 455 | ); 456 | name = LaunchScreen.storyboard; 457 | sourceTree = ""; 458 | }; 459 | /* End PBXVariantGroup section */ 460 | 461 | /* Begin XCBuildConfiguration section */ 462 | D0BCF6681C9141110044448C /* Debug */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | ALWAYS_SEARCH_USER_PATHS = NO; 466 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 467 | CLANG_CXX_LIBRARY = "libc++"; 468 | CLANG_ENABLE_MODULES = YES; 469 | CLANG_ENABLE_OBJC_ARC = YES; 470 | CLANG_WARN_BOOL_CONVERSION = YES; 471 | CLANG_WARN_CONSTANT_CONVERSION = YES; 472 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 473 | CLANG_WARN_EMPTY_BODY = YES; 474 | CLANG_WARN_ENUM_CONVERSION = YES; 475 | CLANG_WARN_INT_CONVERSION = YES; 476 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 477 | CLANG_WARN_UNREACHABLE_CODE = YES; 478 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 479 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 480 | COPY_PHASE_STRIP = NO; 481 | DEBUG_INFORMATION_FORMAT = dwarf; 482 | ENABLE_STRICT_OBJC_MSGSEND = YES; 483 | ENABLE_TESTABILITY = YES; 484 | GCC_C_LANGUAGE_STANDARD = gnu99; 485 | GCC_DYNAMIC_NO_PIC = NO; 486 | GCC_NO_COMMON_BLOCKS = YES; 487 | GCC_OPTIMIZATION_LEVEL = 0; 488 | GCC_PREPROCESSOR_DEFINITIONS = ( 489 | "DEBUG=1", 490 | "$(inherited)", 491 | ); 492 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 493 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 494 | GCC_WARN_UNDECLARED_SELECTOR = YES; 495 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 496 | GCC_WARN_UNUSED_FUNCTION = YES; 497 | GCC_WARN_UNUSED_VARIABLE = YES; 498 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 499 | MTL_ENABLE_DEBUG_INFO = YES; 500 | ONLY_ACTIVE_ARCH = YES; 501 | SDKROOT = iphoneos; 502 | }; 503 | name = Debug; 504 | }; 505 | D0BCF6691C9141110044448C /* Release */ = { 506 | isa = XCBuildConfiguration; 507 | buildSettings = { 508 | ALWAYS_SEARCH_USER_PATHS = NO; 509 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 510 | CLANG_CXX_LIBRARY = "libc++"; 511 | CLANG_ENABLE_MODULES = YES; 512 | CLANG_ENABLE_OBJC_ARC = YES; 513 | CLANG_WARN_BOOL_CONVERSION = YES; 514 | CLANG_WARN_CONSTANT_CONVERSION = YES; 515 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 516 | CLANG_WARN_EMPTY_BODY = YES; 517 | CLANG_WARN_ENUM_CONVERSION = YES; 518 | CLANG_WARN_INT_CONVERSION = YES; 519 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 520 | CLANG_WARN_UNREACHABLE_CODE = YES; 521 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 522 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 523 | COPY_PHASE_STRIP = NO; 524 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 525 | ENABLE_NS_ASSERTIONS = NO; 526 | ENABLE_STRICT_OBJC_MSGSEND = YES; 527 | GCC_C_LANGUAGE_STANDARD = gnu99; 528 | GCC_NO_COMMON_BLOCKS = YES; 529 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 530 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 531 | GCC_WARN_UNDECLARED_SELECTOR = YES; 532 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 533 | GCC_WARN_UNUSED_FUNCTION = YES; 534 | GCC_WARN_UNUSED_VARIABLE = YES; 535 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 536 | MTL_ENABLE_DEBUG_INFO = NO; 537 | SDKROOT = iphoneos; 538 | VALIDATE_PRODUCT = YES; 539 | }; 540 | name = Release; 541 | }; 542 | D0BCF66B1C9141110044448C /* Debug */ = { 543 | isa = XCBuildConfiguration; 544 | buildSettings = { 545 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 546 | INFOPLIST_FILE = QJSlideView/Info.plist; 547 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 548 | PRODUCT_BUNDLE_IDENTIFIER = "-7589026-qq.com.QJSlideView"; 549 | PRODUCT_NAME = "$(TARGET_NAME)"; 550 | }; 551 | name = Debug; 552 | }; 553 | D0BCF66C1C9141110044448C /* Release */ = { 554 | isa = XCBuildConfiguration; 555 | buildSettings = { 556 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 557 | INFOPLIST_FILE = QJSlideView/Info.plist; 558 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 559 | PRODUCT_BUNDLE_IDENTIFIER = "-7589026-qq.com.QJSlideView"; 560 | PRODUCT_NAME = "$(TARGET_NAME)"; 561 | }; 562 | name = Release; 563 | }; 564 | D0BCF66E1C9141110044448C /* Debug */ = { 565 | isa = XCBuildConfiguration; 566 | buildSettings = { 567 | BUNDLE_LOADER = "$(TEST_HOST)"; 568 | INFOPLIST_FILE = QJSlideViewTests/Info.plist; 569 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 570 | PRODUCT_BUNDLE_IDENTIFIER = "-589026-qq.com.QJSlideViewTests"; 571 | PRODUCT_NAME = "$(TARGET_NAME)"; 572 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QJSlideView.app/QJSlideView"; 573 | }; 574 | name = Debug; 575 | }; 576 | D0BCF66F1C9141110044448C /* Release */ = { 577 | isa = XCBuildConfiguration; 578 | buildSettings = { 579 | BUNDLE_LOADER = "$(TEST_HOST)"; 580 | INFOPLIST_FILE = QJSlideViewTests/Info.plist; 581 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 582 | PRODUCT_BUNDLE_IDENTIFIER = "-589026-qq.com.QJSlideViewTests"; 583 | PRODUCT_NAME = "$(TARGET_NAME)"; 584 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QJSlideView.app/QJSlideView"; 585 | }; 586 | name = Release; 587 | }; 588 | D0BCF6711C9141110044448C /* Debug */ = { 589 | isa = XCBuildConfiguration; 590 | buildSettings = { 591 | INFOPLIST_FILE = QJSlideViewUITests/Info.plist; 592 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 593 | PRODUCT_BUNDLE_IDENTIFIER = "-589026-qq.com.QJSlideViewUITests"; 594 | PRODUCT_NAME = "$(TARGET_NAME)"; 595 | TEST_TARGET_NAME = QJSlideView; 596 | USES_XCTRUNNER = YES; 597 | }; 598 | name = Debug; 599 | }; 600 | D0BCF6721C9141110044448C /* Release */ = { 601 | isa = XCBuildConfiguration; 602 | buildSettings = { 603 | INFOPLIST_FILE = QJSlideViewUITests/Info.plist; 604 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 605 | PRODUCT_BUNDLE_IDENTIFIER = "-589026-qq.com.QJSlideViewUITests"; 606 | PRODUCT_NAME = "$(TARGET_NAME)"; 607 | TEST_TARGET_NAME = QJSlideView; 608 | USES_XCTRUNNER = YES; 609 | }; 610 | name = Release; 611 | }; 612 | /* End XCBuildConfiguration section */ 613 | 614 | /* Begin XCConfigurationList section */ 615 | D0BCF6381C9141110044448C /* Build configuration list for PBXProject "QJSlideView" */ = { 616 | isa = XCConfigurationList; 617 | buildConfigurations = ( 618 | D0BCF6681C9141110044448C /* Debug */, 619 | D0BCF6691C9141110044448C /* Release */, 620 | ); 621 | defaultConfigurationIsVisible = 0; 622 | defaultConfigurationName = Release; 623 | }; 624 | D0BCF66A1C9141110044448C /* Build configuration list for PBXNativeTarget "QJSlideView" */ = { 625 | isa = XCConfigurationList; 626 | buildConfigurations = ( 627 | D0BCF66B1C9141110044448C /* Debug */, 628 | D0BCF66C1C9141110044448C /* Release */, 629 | ); 630 | defaultConfigurationIsVisible = 0; 631 | defaultConfigurationName = Release; 632 | }; 633 | D0BCF66D1C9141110044448C /* Build configuration list for PBXNativeTarget "QJSlideViewTests" */ = { 634 | isa = XCConfigurationList; 635 | buildConfigurations = ( 636 | D0BCF66E1C9141110044448C /* Debug */, 637 | D0BCF66F1C9141110044448C /* Release */, 638 | ); 639 | defaultConfigurationIsVisible = 0; 640 | defaultConfigurationName = Release; 641 | }; 642 | D0BCF6701C9141110044448C /* Build configuration list for PBXNativeTarget "QJSlideViewUITests" */ = { 643 | isa = XCConfigurationList; 644 | buildConfigurations = ( 645 | D0BCF6711C9141110044448C /* Debug */, 646 | D0BCF6721C9141110044448C /* Release */, 647 | ); 648 | defaultConfigurationIsVisible = 0; 649 | defaultConfigurationName = Release; 650 | }; 651 | /* End XCConfigurationList section */ 652 | }; 653 | rootObject = D0BCF6351C9141110044448C /* Project object */; 654 | } 655 | -------------------------------------------------------------------------------- /QJSlideView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QJSlideView.xcodeproj/project.xcworkspace/xcuserdata/justin.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinAce/QJSlideView/fd8275358eaa2ff90673c36f30146c82fa51242b/QJSlideView.xcodeproj/project.xcworkspace/xcuserdata/justin.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /QJSlideView.xcodeproj/project.xcworkspace/xcuserdata/justin.xcuserdatad/xcdebugger/Expressions.xcexplist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 13 | 14 | 15 | 16 | 18 | 19 | 21 | 22 | 24 | 25 | 26 | 27 | 29 | 30 | 32 | 33 | 34 | 35 | 37 | 38 | 40 | 41 | 42 | 43 | 45 | 46 | 48 | 49 | 50 | 51 | 53 | 54 | 56 | 57 | 58 | 59 | 61 | 62 | 64 | 65 | 66 | 67 | 69 | 70 | 72 | 73 | 75 | 76 | 77 | 78 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /QJSlideView.xcodeproj/xcuserdata/justin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /QJSlideView.xcodeproj/xcuserdata/justin.xcuserdatad/xcschemes/QJSlideView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /QJSlideView.xcodeproj/xcuserdata/justin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | QJSlideView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D0BCF63C1C9141110044448C 16 | 17 | primary 18 | 19 | 20 | D0BCF6551C9141110044448C 21 | 22 | primary 23 | 24 | 25 | D0BCF6601C9141110044448C 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /QJSlideView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. 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 | -------------------------------------------------------------------------------- /QJSlideView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | #import "NavigationViewController.h" 12 | 13 | @interface AppDelegate () 14 | 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 21 | // Override point for customization after application launch. 22 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 23 | self.window.backgroundColor = [UIColor whiteColor]; 24 | self.window.rootViewController = [[NavigationViewController alloc] initWithRootViewController:[[ViewController alloc] init]]; 25 | [self.window makeKeyAndVisible]; 26 | 27 | return YES; 28 | } 29 | 30 | - (void)applicationWillResignActive:(UIApplication *)application { 31 | // 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. 32 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 33 | } 34 | 35 | - (void)applicationDidEnterBackground:(UIApplication *)application { 36 | // 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. 37 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 38 | } 39 | 40 | - (void)applicationWillEnterForeground:(UIApplication *)application { 41 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 42 | } 43 | 44 | - (void)applicationDidBecomeActive:(UIApplication *)application { 45 | // 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. 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 | @end 53 | -------------------------------------------------------------------------------- /QJSlideView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /QJSlideView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /QJSlideView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /QJSlideView/Helper.h: -------------------------------------------------------------------------------- 1 | // 2 | // Helper.h 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/12. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @interface Helper : NSObject 14 | 15 | + (UIView *)initLoadingViewInView; 16 | @end 17 | -------------------------------------------------------------------------------- /QJSlideView/Helper.m: -------------------------------------------------------------------------------- 1 | // 2 | // Helper.m 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/12. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import "Helper.h" 10 | #import "Masonry.h" 11 | 12 | @implementation Helper 13 | 14 | + (UIView *)initLoadingViewInView 15 | { 16 | UIView *window = [UIApplication sharedApplication].keyWindow; 17 | UIView *loadingBgView = [[UIView alloc] init]; 18 | loadingBgView.translatesAutoresizingMaskIntoConstraints = NO; 19 | loadingBgView.backgroundColor = [UIColor clearColor]; 20 | [window addSubview:loadingBgView]; 21 | 22 | UIView *bgView = [[UIView alloc] init]; 23 | bgView.layer.cornerRadius = 5; 24 | bgView.translatesAutoresizingMaskIntoConstraints = NO; 25 | bgView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5]; 26 | [loadingBgView addSubview:bgView]; 27 | 28 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 29 | loadingView.translatesAutoresizingMaskIntoConstraints = NO; 30 | [loadingBgView addSubview:loadingView]; 31 | 32 | [loadingBgView mas_makeConstraints:^(MASConstraintMaker *make) { 33 | make.left.right.top.bottom.equalTo(window); 34 | }]; 35 | 36 | [bgView mas_makeConstraints:^(MASConstraintMaker *make) { 37 | make.size.mas_equalTo(CGSizeMake(100, 100)); 38 | make.centerX.equalTo(window.mas_centerX); 39 | make.centerY.equalTo(window.mas_centerY); 40 | }]; 41 | 42 | [loadingView mas_makeConstraints:^(MASConstraintMaker *make) { 43 | make.centerX.equalTo(window.mas_centerX); 44 | make.centerY.equalTo(window.mas_centerY); 45 | 46 | }]; 47 | 48 | [loadingView startAnimating]; 49 | 50 | return loadingBgView; 51 | } 52 | 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /QJSlideView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * Enables Constraints to be created with chainable syntax 13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint) 14 | * or a group of NSLayoutConstraints (MASComposisteConstraint) 15 | */ 16 | @interface MASConstraint : NSObject 17 | 18 | // Chaining Support 19 | 20 | /** 21 | * Modifies the NSLayoutConstraint constant, 22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 24 | */ 25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets; 26 | 27 | /** 28 | * Modifies the NSLayoutConstraint constant, 29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 31 | */ 32 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 38 | */ 39 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant 43 | */ 44 | - (MASConstraint * (^)(CGFloat offset))offset; 45 | 46 | /** 47 | * Modifies the NSLayoutConstraint constant based on a value type 48 | */ 49 | - (MASConstraint * (^)(NSValue *value))valueOffset; 50 | 51 | /** 52 | * Sets the NSLayoutConstraint multiplier property 53 | */ 54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 55 | 56 | /** 57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 58 | */ 59 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 60 | 61 | /** 62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 63 | */ 64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 65 | 66 | /** 67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 68 | */ 69 | - (MASConstraint * (^)())priorityLow; 70 | 71 | /** 72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 73 | */ 74 | - (MASConstraint * (^)())priorityMedium; 75 | 76 | /** 77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 78 | */ 79 | - (MASConstraint * (^)())priorityHigh; 80 | 81 | /** 82 | * Sets the constraint relation to NSLayoutRelationEqual 83 | * returns a block which accepts one of the following: 84 | * MASViewAttribute, UIView, NSValue, NSArray 85 | * see readme for more details. 86 | */ 87 | - (MASConstraint * (^)(id attr))equalTo; 88 | 89 | /** 90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 91 | * returns a block which accepts one of the following: 92 | * MASViewAttribute, UIView, NSValue, NSArray 93 | * see readme for more details. 94 | */ 95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 96 | 97 | /** 98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 99 | * returns a block which accepts one of the following: 100 | * MASViewAttribute, UIView, NSValue, NSArray 101 | * see readme for more details. 102 | */ 103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 104 | 105 | /** 106 | * Optional semantic property which has no effect but improves the readability of constraint 107 | */ 108 | - (MASConstraint *)with; 109 | 110 | /** 111 | * Optional semantic property which has no effect but improves the readability of constraint 112 | */ 113 | - (MASConstraint *)and; 114 | 115 | /** 116 | * Creates a new MASCompositeConstraint with the called attribute and reciever 117 | */ 118 | - (MASConstraint *)left; 119 | - (MASConstraint *)top; 120 | - (MASConstraint *)right; 121 | - (MASConstraint *)bottom; 122 | - (MASConstraint *)leading; 123 | - (MASConstraint *)trailing; 124 | - (MASConstraint *)width; 125 | - (MASConstraint *)height; 126 | - (MASConstraint *)centerX; 127 | - (MASConstraint *)centerY; 128 | - (MASConstraint *)baseline; 129 | 130 | #if TARGET_OS_IPHONE || TARGET_OS_TV 131 | 132 | - (MASConstraint *)leftMargin; 133 | - (MASConstraint *)rightMargin; 134 | - (MASConstraint *)topMargin; 135 | - (MASConstraint *)bottomMargin; 136 | - (MASConstraint *)leadingMargin; 137 | - (MASConstraint *)trailingMargin; 138 | - (MASConstraint *)centerXWithinMargins; 139 | - (MASConstraint *)centerYWithinMargins; 140 | 141 | #endif 142 | 143 | 144 | /** 145 | * Sets the constraint debug name 146 | */ 147 | - (MASConstraint * (^)(id key))key; 148 | 149 | // NSLayoutConstraint constant Setters 150 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 151 | 152 | /** 153 | * Modifies the NSLayoutConstraint constant, 154 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 155 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 156 | */ 157 | - (void)setInsets:(MASEdgeInsets)insets; 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant, 161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 162 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 163 | */ 164 | - (void)setSizeOffset:(CGSize)sizeOffset; 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 170 | */ 171 | - (void)setCenterOffset:(CGPoint)centerOffset; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant 175 | */ 176 | - (void)setOffset:(CGFloat)offset; 177 | 178 | 179 | // NSLayoutConstraint Installation support 180 | 181 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 182 | /** 183 | * Whether or not to go through the animator proxy when modifying the constraint 184 | */ 185 | @property (nonatomic, copy, readonly) MASConstraint *animator; 186 | #endif 187 | 188 | /** 189 | * Activates an NSLayoutConstraint if it's supported by an OS. 190 | * Invokes install otherwise. 191 | */ 192 | - (void)activate; 193 | 194 | /** 195 | * Deactivates previously installed/activated NSLayoutConstraint. 196 | */ 197 | - (void)deactivate; 198 | 199 | /** 200 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 201 | */ 202 | - (void)install; 203 | 204 | /** 205 | * Removes previously installed NSLayoutConstraint 206 | */ 207 | - (void)uninstall; 208 | 209 | @end 210 | 211 | 212 | /** 213 | * Convenience auto-boxing macros for MASConstraint methods. 214 | * 215 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 216 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 217 | */ 218 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 219 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 220 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 221 | 222 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 223 | 224 | 225 | #ifdef MAS_SHORTHAND_GLOBALS 226 | 227 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 228 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 229 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 230 | 231 | #define offset(...) mas_offset(__VA_ARGS__) 232 | 233 | #endif 234 | 235 | 236 | @interface MASConstraint (AutoboxingSupport) 237 | 238 | /** 239 | * Aliases to corresponding relation methods (for shorthand macros) 240 | * Also needed to aid autocompletion 241 | */ 242 | - (MASConstraint * (^)(id attr))mas_equalTo; 243 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 244 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 245 | 246 | /** 247 | * A dummy method to aid autocompletion 248 | */ 249 | - (MASConstraint * (^)(id offset))mas_offset; 250 | 251 | @end 252 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 1/20/14. 6 | // 7 | 8 | #import "MASConstraint.h" 9 | #import "MASConstraint+Private.h" 10 | 11 | #define MASMethodNotImplemented() \ 12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \ 13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ 14 | userInfo:nil] 15 | 16 | @implementation MASConstraint 17 | 18 | #pragma mark - Init 19 | 20 | - (id)init { 21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); 22 | return [super init]; 23 | } 24 | 25 | #pragma mark - NSLayoutRelation proxies 26 | 27 | - (MASConstraint * (^)(id))equalTo { 28 | return ^id(id attribute) { 29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 30 | }; 31 | } 32 | 33 | - (MASConstraint * (^)(id))mas_equalTo { 34 | return ^id(id attribute) { 35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 36 | }; 37 | } 38 | 39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo { 40 | return ^id(id attribute) { 41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 42 | }; 43 | } 44 | 45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { 46 | return ^id(id attribute) { 47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 48 | }; 49 | } 50 | 51 | - (MASConstraint * (^)(id))lessThanOrEqualTo { 52 | return ^id(id attribute) { 53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 54 | }; 55 | } 56 | 57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { 58 | return ^id(id attribute) { 59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 60 | }; 61 | } 62 | 63 | #pragma mark - MASLayoutPriority proxies 64 | 65 | - (MASConstraint * (^)())priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)())priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)())priorityHigh { 80 | return ^id{ 81 | self.priority(MASLayoutPriorityDefaultHigh); 82 | return self; 83 | }; 84 | } 85 | 86 | #pragma mark - NSLayoutConstraint constant proxies 87 | 88 | - (MASConstraint * (^)(MASEdgeInsets))insets { 89 | return ^id(MASEdgeInsets insets){ 90 | self.insets = insets; 91 | return self; 92 | }; 93 | } 94 | 95 | - (MASConstraint * (^)(CGSize))sizeOffset { 96 | return ^id(CGSize offset) { 97 | self.sizeOffset = offset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGPoint))centerOffset { 103 | return ^id(CGPoint offset) { 104 | self.centerOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGFloat))offset { 110 | return ^id(CGFloat offset){ 111 | self.offset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(NSValue *value))valueOffset { 117 | return ^id(NSValue *offset) { 118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 119 | [self setLayoutConstantWithValue:offset]; 120 | return self; 121 | }; 122 | } 123 | 124 | - (MASConstraint * (^)(id offset))mas_offset { 125 | // Will never be called due to macro 126 | return nil; 127 | } 128 | 129 | #pragma mark - NSLayoutConstraint constant setter 130 | 131 | - (void)setLayoutConstantWithValue:(NSValue *)value { 132 | if ([value isKindOfClass:NSNumber.class]) { 133 | self.offset = [(NSNumber *)value doubleValue]; 134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 135 | CGPoint point; 136 | [value getValue:&point]; 137 | self.centerOffset = point; 138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 139 | CGSize size; 140 | [value getValue:&size]; 141 | self.sizeOffset = size; 142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 143 | MASEdgeInsets insets; 144 | [value getValue:&insets]; 145 | self.insets = insets; 146 | } else { 147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 148 | } 149 | } 150 | 151 | #pragma mark - Semantic properties 152 | 153 | - (MASConstraint *)with { 154 | return self; 155 | } 156 | 157 | - (MASConstraint *)and { 158 | return self; 159 | } 160 | 161 | #pragma mark - Chaining 162 | 163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 164 | MASMethodNotImplemented(); 165 | } 166 | 167 | - (MASConstraint *)left { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 169 | } 170 | 171 | - (MASConstraint *)top { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 173 | } 174 | 175 | - (MASConstraint *)right { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 177 | } 178 | 179 | - (MASConstraint *)bottom { 180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 181 | } 182 | 183 | - (MASConstraint *)leading { 184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 185 | } 186 | 187 | - (MASConstraint *)trailing { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 189 | } 190 | 191 | - (MASConstraint *)width { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 193 | } 194 | 195 | - (MASConstraint *)height { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 197 | } 198 | 199 | - (MASConstraint *)centerX { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 201 | } 202 | 203 | - (MASConstraint *)centerY { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 205 | } 206 | 207 | - (MASConstraint *)baseline { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 209 | } 210 | 211 | #if TARGET_OS_IPHONE || TARGET_OS_TV 212 | 213 | - (MASConstraint *)leftMargin { 214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 215 | } 216 | 217 | - (MASConstraint *)rightMargin { 218 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 219 | } 220 | 221 | - (MASConstraint *)topMargin { 222 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 223 | } 224 | 225 | - (MASConstraint *)bottomMargin { 226 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 227 | } 228 | 229 | - (MASConstraint *)leadingMargin { 230 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 231 | } 232 | 233 | - (MASConstraint *)trailingMargin { 234 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 235 | } 236 | 237 | - (MASConstraint *)centerXWithinMargins { 238 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 239 | } 240 | 241 | - (MASConstraint *)centerYWithinMargins { 242 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 243 | } 244 | 245 | #endif 246 | 247 | #pragma mark - Abstract 248 | 249 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 250 | 251 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 252 | 253 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 254 | 255 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 256 | 257 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 258 | 259 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 260 | 261 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 262 | 263 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 264 | 265 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 266 | 267 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 268 | 269 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 270 | 271 | #endif 272 | 273 | - (void)activate { MASMethodNotImplemented(); } 274 | 275 | - (void)deactivate { MASMethodNotImplemented(); } 276 | 277 | - (void)install { MASMethodNotImplemented(); } 278 | 279 | - (void)uninstall { MASMethodNotImplemented(); } 280 | 281 | @end 282 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if TARGET_OS_IPHONE || TARGET_OS_TV 26 | 27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 35 | 36 | #endif 37 | 38 | }; 39 | 40 | /** 41 | * Provides factory methods for creating MASConstraints. 42 | * Constraints are collected until they are ready to be installed 43 | * 44 | */ 45 | @interface MASConstraintMaker : NSObject 46 | 47 | /** 48 | * The following properties return a new MASViewConstraint 49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 50 | */ 51 | @property (nonatomic, strong, readonly) MASConstraint *left; 52 | @property (nonatomic, strong, readonly) MASConstraint *top; 53 | @property (nonatomic, strong, readonly) MASConstraint *right; 54 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 55 | @property (nonatomic, strong, readonly) MASConstraint *leading; 56 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 57 | @property (nonatomic, strong, readonly) MASConstraint *width; 58 | @property (nonatomic, strong, readonly) MASConstraint *height; 59 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 60 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 61 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 62 | 63 | #if TARGET_OS_IPHONE || TARGET_OS_TV 64 | 65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 73 | 74 | #endif 75 | 76 | /** 77 | * Returns a block which creates a new MASCompositeConstraint with the first item set 78 | * to the makers associated view and children corresponding to the set bits in the 79 | * MASAttribute parameter. Combine multiple attributes via binary-or. 80 | */ 81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 82 | 83 | /** 84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 86 | * with the first item set to the makers associated view 87 | */ 88 | @property (nonatomic, strong, readonly) MASConstraint *edges; 89 | 90 | /** 91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 92 | * which generates the appropriate MASViewConstraint children (width, height) 93 | * with the first item set to the makers associated view 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *size; 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 99 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *center; 103 | 104 | /** 105 | * Whether or not to check for an existing constraint instead of adding constraint 106 | */ 107 | @property (nonatomic, assign) BOOL updateExisting; 108 | 109 | /** 110 | * Whether or not to remove existing constraints prior to installing 111 | */ 112 | @property (nonatomic, assign) BOOL removeExisting; 113 | 114 | /** 115 | * initialises the maker with a default view 116 | * 117 | * @param view any MASConstrait are created with this view as the first item 118 | * 119 | * @return a new MASConstraintMaker 120 | */ 121 | - (id)initWithView:(MAS_VIEW *)view; 122 | 123 | /** 124 | * Calls install method on any MASConstraints which have been created by this maker 125 | * 126 | * @return an array of all the installed MASConstraints 127 | */ 128 | - (NSArray *)install; 129 | 130 | - (MASConstraint * (^)(dispatch_block_t))group; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASConstraintMaker.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraintMaker.h" 10 | #import "MASViewConstraint.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASConstraint+Private.h" 13 | #import "MASViewAttribute.h" 14 | #import "View+MASAdditions.h" 15 | 16 | @interface MASConstraintMaker () 17 | 18 | @property (nonatomic, weak) MAS_VIEW *view; 19 | @property (nonatomic, strong) NSMutableArray *constraints; 20 | 21 | @end 22 | 23 | @implementation MASConstraintMaker 24 | 25 | - (id)initWithView:(MAS_VIEW *)view { 26 | self = [super init]; 27 | if (!self) return nil; 28 | 29 | self.view = view; 30 | self.constraints = NSMutableArray.new; 31 | 32 | return self; 33 | } 34 | 35 | - (NSArray *)install { 36 | if (self.removeExisting) { 37 | NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view]; 38 | for (MASConstraint *constraint in installedConstraints) { 39 | [constraint uninstall]; 40 | } 41 | } 42 | NSArray *constraints = self.constraints.copy; 43 | for (MASConstraint *constraint in constraints) { 44 | constraint.updateExisting = self.updateExisting; 45 | [constraint install]; 46 | } 47 | [self.constraints removeAllObjects]; 48 | return constraints; 49 | } 50 | 51 | #pragma mark - MASConstraintDelegate 52 | 53 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 54 | NSUInteger index = [self.constraints indexOfObject:constraint]; 55 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 56 | [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint]; 57 | } 58 | 59 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 60 | MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute]; 61 | MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute]; 62 | if ([constraint isKindOfClass:MASViewConstraint.class]) { 63 | //replace with composite constraint 64 | NSArray *children = @[constraint, newConstraint]; 65 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 66 | compositeConstraint.delegate = self; 67 | [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint]; 68 | return compositeConstraint; 69 | } 70 | if (!constraint) { 71 | newConstraint.delegate = self; 72 | [self.constraints addObject:newConstraint]; 73 | } 74 | return newConstraint; 75 | } 76 | 77 | - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs { 78 | __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading 79 | | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX 80 | | MASAttributeCenterY | MASAttributeBaseline 81 | #if TARGET_OS_IPHONE || TARGET_OS_TV 82 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin 83 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins 84 | | MASAttributeCenterYWithinMargins 85 | #endif 86 | ); 87 | 88 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); 89 | 90 | NSMutableArray *attributes = [NSMutableArray array]; 91 | 92 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; 93 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; 94 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; 95 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; 96 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; 97 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; 98 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; 99 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; 100 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; 101 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; 102 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; 103 | 104 | #if TARGET_OS_IPHONE || TARGET_OS_TV 105 | 106 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin]; 107 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin]; 108 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin]; 109 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin]; 110 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin]; 111 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin]; 112 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins]; 113 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins]; 114 | 115 | #endif 116 | 117 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; 118 | 119 | for (MASViewAttribute *a in attributes) { 120 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; 121 | } 122 | 123 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 124 | constraint.delegate = self; 125 | [self.constraints addObject:constraint]; 126 | return constraint; 127 | } 128 | 129 | #pragma mark - standard Attributes 130 | 131 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 132 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; 133 | } 134 | 135 | - (MASConstraint *)left { 136 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 137 | } 138 | 139 | - (MASConstraint *)top { 140 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 141 | } 142 | 143 | - (MASConstraint *)right { 144 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 145 | } 146 | 147 | - (MASConstraint *)bottom { 148 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 149 | } 150 | 151 | - (MASConstraint *)leading { 152 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 153 | } 154 | 155 | - (MASConstraint *)trailing { 156 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 157 | } 158 | 159 | - (MASConstraint *)width { 160 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 161 | } 162 | 163 | - (MASConstraint *)height { 164 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 165 | } 166 | 167 | - (MASConstraint *)centerX { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 169 | } 170 | 171 | - (MASConstraint *)centerY { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 173 | } 174 | 175 | - (MASConstraint *)baseline { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 177 | } 178 | 179 | - (MASConstraint *(^)(MASAttribute))attributes { 180 | return ^(MASAttribute attrs){ 181 | return [self addConstraintWithAttributes:attrs]; 182 | }; 183 | } 184 | 185 | #if TARGET_OS_IPHONE || TARGET_OS_TV 186 | 187 | - (MASConstraint *)leftMargin { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 189 | } 190 | 191 | - (MASConstraint *)rightMargin { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 193 | } 194 | 195 | - (MASConstraint *)topMargin { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 197 | } 198 | 199 | - (MASConstraint *)bottomMargin { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 201 | } 202 | 203 | - (MASConstraint *)leadingMargin { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 205 | } 206 | 207 | - (MASConstraint *)trailingMargin { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 209 | } 210 | 211 | - (MASConstraint *)centerXWithinMargins { 212 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 213 | } 214 | 215 | - (MASConstraint *)centerYWithinMargins { 216 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 217 | } 218 | 219 | #endif 220 | 221 | 222 | #pragma mark - composite Attributes 223 | 224 | - (MASConstraint *)edges { 225 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; 226 | } 227 | 228 | - (MASConstraint *)size { 229 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; 230 | } 231 | 232 | - (MASConstraint *)center { 233 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; 234 | } 235 | 236 | #pragma mark - grouping 237 | 238 | - (MASConstraint *(^)(dispatch_block_t group))group { 239 | return ^id(dispatch_block_t group) { 240 | NSInteger previousCount = self.constraints.count; 241 | group(); 242 | 243 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; 244 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 245 | constraint.delegate = self; 246 | return constraint; 247 | }; 248 | } 249 | 250 | @end 251 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | #if TARGET_OS_IPHONE || TARGET_OS_TV 14 | 15 | #import 16 | #define MAS_VIEW UIView 17 | #define MAS_VIEW_CONTROLLER UIViewController 18 | #define MASEdgeInsets UIEdgeInsets 19 | 20 | typedef UILayoutPriority MASLayoutPriority; 21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 26 | 27 | #elif TARGET_OS_MAC 28 | 29 | #import 30 | #define MAS_VIEW NSView 31 | #define MASEdgeInsets NSEdgeInsets 32 | 33 | typedef NSLayoutPriority MASLayoutPriority; 34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 42 | 43 | #endif 44 | 45 | /** 46 | * Allows you to attach keys to objects matching the variable names passed. 47 | * 48 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 49 | * 50 | * is equivalent to: 51 | * 52 | * MASAttachKeys(view1, view2); 53 | */ 54 | #define MASAttachKeys(...) \ 55 | { \ 56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 57 | for (id key in keyPairs.allKeys) { \ 58 | id obj = keyPairs[key]; \ 59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 60 | @"Cannot attach mas_key to %@", obj); \ 61 | [obj setMas_key:key]; \ 62 | } \ 63 | } 64 | 65 | /** 66 | * Used to create object hashes 67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 68 | */ 69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 71 | 72 | /** 73 | * Given a scalar or struct value, wraps it in NSValue 74 | * Based on EXPObjectify: https://github.com/specta/expecta 75 | */ 76 | static inline id _MASBoxValue(const char *type, ...) { 77 | va_list v; 78 | va_start(v, type); 79 | id obj = nil; 80 | if (strcmp(type, @encode(id)) == 0) { 81 | id actual = va_arg(v, id); 82 | obj = actual; 83 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 85 | obj = [NSValue value:&actual withObjCType:type]; 86 | } else if (strcmp(type, @encode(CGSize)) == 0) { 87 | CGSize actual = (CGSize)va_arg(v, CGSize); 88 | obj = [NSValue value:&actual withObjCType:type]; 89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 91 | obj = [NSValue value:&actual withObjCType:type]; 92 | } else if (strcmp(type, @encode(double)) == 0) { 93 | double actual = (double)va_arg(v, double); 94 | obj = [NSNumber numberWithDouble:actual]; 95 | } else if (strcmp(type, @encode(float)) == 0) { 96 | float actual = (float)va_arg(v, double); 97 | obj = [NSNumber numberWithFloat:actual]; 98 | } else if (strcmp(type, @encode(int)) == 0) { 99 | int actual = (int)va_arg(v, int); 100 | obj = [NSNumber numberWithInt:actual]; 101 | } else if (strcmp(type, @encode(long)) == 0) { 102 | long actual = (long)va_arg(v, long); 103 | obj = [NSNumber numberWithLong:actual]; 104 | } else if (strcmp(type, @encode(long long)) == 0) { 105 | long long actual = (long long)va_arg(v, long long); 106 | obj = [NSNumber numberWithLongLong:actual]; 107 | } else if (strcmp(type, @encode(short)) == 0) { 108 | short actual = (short)va_arg(v, int); 109 | obj = [NSNumber numberWithShort:actual]; 110 | } else if (strcmp(type, @encode(char)) == 0) { 111 | char actual = (char)va_arg(v, int); 112 | obj = [NSNumber numberWithChar:actual]; 113 | } else if (strcmp(type, @encode(bool)) == 0) { 114 | bool actual = (bool)va_arg(v, int); 115 | obj = [NSNumber numberWithBool:actual]; 116 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 118 | obj = [NSNumber numberWithUnsignedChar:actual]; 119 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 121 | obj = [NSNumber numberWithUnsignedInt:actual]; 122 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 124 | obj = [NSNumber numberWithUnsignedLong:actual]; 125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 127 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 128 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 130 | obj = [NSNumber numberWithUnsignedShort:actual]; 131 | } 132 | va_end(v); 133 | return obj; 134 | } 135 | 136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 137 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/MASViewConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASLayoutConstraint.h" 13 | #import "View+MASAdditions.h" 14 | #import 15 | 16 | @interface MAS_VIEW (MASConstraints) 17 | 18 | @property (nonatomic, readonly) NSMutableSet *mas_installedConstraints; 19 | 20 | @end 21 | 22 | @implementation MAS_VIEW (MASConstraints) 23 | 24 | static char kInstalledConstraintsKey; 25 | 26 | - (NSMutableSet *)mas_installedConstraints { 27 | NSMutableSet *constraints = objc_getAssociatedObject(self, &kInstalledConstraintsKey); 28 | if (!constraints) { 29 | constraints = [NSMutableSet set]; 30 | objc_setAssociatedObject(self, &kInstalledConstraintsKey, constraints, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 31 | } 32 | return constraints; 33 | } 34 | 35 | @end 36 | 37 | 38 | @interface MASViewConstraint () 39 | 40 | @property (nonatomic, strong, readwrite) MASViewAttribute *secondViewAttribute; 41 | @property (nonatomic, weak) MAS_VIEW *installedView; 42 | @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint; 43 | @property (nonatomic, assign) NSLayoutRelation layoutRelation; 44 | @property (nonatomic, assign) MASLayoutPriority layoutPriority; 45 | @property (nonatomic, assign) CGFloat layoutMultiplier; 46 | @property (nonatomic, assign) CGFloat layoutConstant; 47 | @property (nonatomic, assign) BOOL hasLayoutRelation; 48 | @property (nonatomic, strong) id mas_key; 49 | @property (nonatomic, assign) BOOL useAnimator; 50 | 51 | @end 52 | 53 | @implementation MASViewConstraint 54 | 55 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute { 56 | self = [super init]; 57 | if (!self) return nil; 58 | 59 | _firstViewAttribute = firstViewAttribute; 60 | self.layoutPriority = MASLayoutPriorityRequired; 61 | self.layoutMultiplier = 1; 62 | 63 | return self; 64 | } 65 | 66 | #pragma mark - NSCoping 67 | 68 | - (id)copyWithZone:(NSZone __unused *)zone { 69 | MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute]; 70 | constraint.layoutConstant = self.layoutConstant; 71 | constraint.layoutRelation = self.layoutRelation; 72 | constraint.layoutPriority = self.layoutPriority; 73 | constraint.layoutMultiplier = self.layoutMultiplier; 74 | constraint.delegate = self.delegate; 75 | return constraint; 76 | } 77 | 78 | #pragma mark - Public 79 | 80 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view { 81 | return [view.mas_installedConstraints allObjects]; 82 | } 83 | 84 | #pragma mark - Private 85 | 86 | - (void)setLayoutConstant:(CGFloat)layoutConstant { 87 | _layoutConstant = layoutConstant; 88 | 89 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 90 | if (self.useAnimator) { 91 | [self.layoutConstraint.animator setConstant:layoutConstant]; 92 | } else { 93 | self.layoutConstraint.constant = layoutConstant; 94 | } 95 | #else 96 | self.layoutConstraint.constant = layoutConstant; 97 | #endif 98 | } 99 | 100 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation { 101 | _layoutRelation = layoutRelation; 102 | self.hasLayoutRelation = YES; 103 | } 104 | 105 | - (BOOL)supportsActiveProperty { 106 | return [self.layoutConstraint respondsToSelector:@selector(isActive)]; 107 | } 108 | 109 | - (BOOL)isActive { 110 | BOOL active = YES; 111 | if ([self supportsActiveProperty]) { 112 | active = [self.layoutConstraint isActive]; 113 | } 114 | 115 | return active; 116 | } 117 | 118 | - (BOOL)hasBeenInstalled { 119 | return (self.layoutConstraint != nil) && [self isActive]; 120 | } 121 | 122 | - (void)setSecondViewAttribute:(id)secondViewAttribute { 123 | if ([secondViewAttribute isKindOfClass:NSValue.class]) { 124 | [self setLayoutConstantWithValue:secondViewAttribute]; 125 | } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) { 126 | _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute]; 127 | } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) { 128 | _secondViewAttribute = secondViewAttribute; 129 | } else { 130 | NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute); 131 | } 132 | } 133 | 134 | #pragma mark - NSLayoutConstraint multiplier proxies 135 | 136 | - (MASConstraint * (^)(CGFloat))multipliedBy { 137 | return ^id(CGFloat multiplier) { 138 | NSAssert(!self.hasBeenInstalled, 139 | @"Cannot modify constraint multiplier after it has been installed"); 140 | 141 | self.layoutMultiplier = multiplier; 142 | return self; 143 | }; 144 | } 145 | 146 | 147 | - (MASConstraint * (^)(CGFloat))dividedBy { 148 | return ^id(CGFloat divider) { 149 | NSAssert(!self.hasBeenInstalled, 150 | @"Cannot modify constraint multiplier after it has been installed"); 151 | 152 | self.layoutMultiplier = 1.0/divider; 153 | return self; 154 | }; 155 | } 156 | 157 | #pragma mark - MASLayoutPriority proxy 158 | 159 | - (MASConstraint * (^)(MASLayoutPriority))priority { 160 | return ^id(MASLayoutPriority priority) { 161 | NSAssert(!self.hasBeenInstalled, 162 | @"Cannot modify constraint priority after it has been installed"); 163 | 164 | self.layoutPriority = priority; 165 | return self; 166 | }; 167 | } 168 | 169 | #pragma mark - NSLayoutRelation proxy 170 | 171 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 172 | return ^id(id attribute, NSLayoutRelation relation) { 173 | if ([attribute isKindOfClass:NSArray.class]) { 174 | NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation"); 175 | NSMutableArray *children = NSMutableArray.new; 176 | for (id attr in attribute) { 177 | MASViewConstraint *viewConstraint = [self copy]; 178 | viewConstraint.secondViewAttribute = attr; 179 | [children addObject:viewConstraint]; 180 | } 181 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 182 | compositeConstraint.delegate = self.delegate; 183 | [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint]; 184 | return compositeConstraint; 185 | } else { 186 | NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation"); 187 | self.layoutRelation = relation; 188 | self.secondViewAttribute = attribute; 189 | return self; 190 | } 191 | }; 192 | } 193 | 194 | #pragma mark - Semantic properties 195 | 196 | - (MASConstraint *)with { 197 | return self; 198 | } 199 | 200 | - (MASConstraint *)and { 201 | return self; 202 | } 203 | 204 | #pragma mark - attribute chaining 205 | 206 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 207 | NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation"); 208 | 209 | return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 210 | } 211 | 212 | #pragma mark - Animator proxy 213 | 214 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 215 | 216 | - (MASConstraint *)animator { 217 | self.useAnimator = YES; 218 | return self; 219 | } 220 | 221 | #endif 222 | 223 | #pragma mark - debug helpers 224 | 225 | - (MASConstraint * (^)(id))key { 226 | return ^id(id key) { 227 | self.mas_key = key; 228 | return self; 229 | }; 230 | } 231 | 232 | #pragma mark - NSLayoutConstraint constant setters 233 | 234 | - (void)setInsets:(MASEdgeInsets)insets { 235 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 236 | switch (layoutAttribute) { 237 | case NSLayoutAttributeLeft: 238 | case NSLayoutAttributeLeading: 239 | self.layoutConstant = insets.left; 240 | break; 241 | case NSLayoutAttributeTop: 242 | self.layoutConstant = insets.top; 243 | break; 244 | case NSLayoutAttributeBottom: 245 | self.layoutConstant = -insets.bottom; 246 | break; 247 | case NSLayoutAttributeRight: 248 | case NSLayoutAttributeTrailing: 249 | self.layoutConstant = -insets.right; 250 | break; 251 | default: 252 | break; 253 | } 254 | } 255 | 256 | - (void)setOffset:(CGFloat)offset { 257 | self.layoutConstant = offset; 258 | } 259 | 260 | - (void)setSizeOffset:(CGSize)sizeOffset { 261 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 262 | switch (layoutAttribute) { 263 | case NSLayoutAttributeWidth: 264 | self.layoutConstant = sizeOffset.width; 265 | break; 266 | case NSLayoutAttributeHeight: 267 | self.layoutConstant = sizeOffset.height; 268 | break; 269 | default: 270 | break; 271 | } 272 | } 273 | 274 | - (void)setCenterOffset:(CGPoint)centerOffset { 275 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 276 | switch (layoutAttribute) { 277 | case NSLayoutAttributeCenterX: 278 | self.layoutConstant = centerOffset.x; 279 | break; 280 | case NSLayoutAttributeCenterY: 281 | self.layoutConstant = centerOffset.y; 282 | break; 283 | default: 284 | break; 285 | } 286 | } 287 | 288 | #pragma mark - MASConstraint 289 | 290 | - (void)activate { 291 | if ([self supportsActiveProperty] && self.layoutConstraint) { 292 | if (self.hasBeenInstalled) { 293 | return; 294 | } 295 | self.layoutConstraint.active = YES; 296 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; 297 | } else { 298 | [self install]; 299 | } 300 | } 301 | 302 | - (void)deactivate { 303 | if ([self supportsActiveProperty]) { 304 | self.layoutConstraint.active = NO; 305 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 306 | } else { 307 | [self uninstall]; 308 | } 309 | } 310 | 311 | - (void)install { 312 | if (self.hasBeenInstalled) { 313 | return; 314 | } 315 | 316 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item; 317 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute; 318 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item; 319 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute; 320 | 321 | // alignment attributes must have a secondViewAttribute 322 | // therefore we assume that is refering to superview 323 | // eg make.left.equalTo(@10) 324 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) { 325 | secondLayoutItem = self.firstViewAttribute.view.superview; 326 | secondLayoutAttribute = firstLayoutAttribute; 327 | } 328 | 329 | MASLayoutConstraint *layoutConstraint 330 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem 331 | attribute:firstLayoutAttribute 332 | relatedBy:self.layoutRelation 333 | toItem:secondLayoutItem 334 | attribute:secondLayoutAttribute 335 | multiplier:self.layoutMultiplier 336 | constant:self.layoutConstant]; 337 | 338 | layoutConstraint.priority = self.layoutPriority; 339 | layoutConstraint.mas_key = self.mas_key; 340 | 341 | if (self.secondViewAttribute.view) { 342 | MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view]; 343 | NSAssert(closestCommonSuperview, 344 | @"couldn't find a common superview for %@ and %@", 345 | self.firstViewAttribute.view, self.secondViewAttribute.view); 346 | self.installedView = closestCommonSuperview; 347 | } else if (self.firstViewAttribute.isSizeAttribute) { 348 | self.installedView = self.firstViewAttribute.view; 349 | } else { 350 | self.installedView = self.firstViewAttribute.view.superview; 351 | } 352 | 353 | 354 | MASLayoutConstraint *existingConstraint = nil; 355 | if (self.updateExisting) { 356 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint]; 357 | } 358 | if (existingConstraint) { 359 | // just update the constant 360 | existingConstraint.constant = layoutConstraint.constant; 361 | self.layoutConstraint = existingConstraint; 362 | } else { 363 | [self.installedView addConstraint:layoutConstraint]; 364 | self.layoutConstraint = layoutConstraint; 365 | [firstLayoutItem.mas_installedConstraints addObject:self]; 366 | } 367 | } 368 | 369 | - (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint { 370 | // check if any constraints are the same apart from the only mutable property constant 371 | 372 | // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints 373 | // and they are likely to be added first. 374 | for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) { 375 | if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue; 376 | if (existingConstraint.firstItem != layoutConstraint.firstItem) continue; 377 | if (existingConstraint.secondItem != layoutConstraint.secondItem) continue; 378 | if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue; 379 | if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue; 380 | if (existingConstraint.relation != layoutConstraint.relation) continue; 381 | if (existingConstraint.multiplier != layoutConstraint.multiplier) continue; 382 | if (existingConstraint.priority != layoutConstraint.priority) continue; 383 | 384 | return (id)existingConstraint; 385 | } 386 | return nil; 387 | } 388 | 389 | - (void)uninstall { 390 | [self.installedView removeConstraint:self.layoutConstraint]; 391 | self.layoutConstraint = nil; 392 | self.installedView = nil; 393 | 394 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 395 | } 396 | 397 | @end 398 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 42 | if (self.count < 2) { 43 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 44 | return; 45 | } 46 | 47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 48 | if (axisType == MASAxisTypeHorizontal) { 49 | MAS_VIEW *prev; 50 | for (int i = 0; i < self.count; i++) { 51 | MAS_VIEW *v = self[i]; 52 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 53 | if (prev) { 54 | make.width.equalTo(prev); 55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing); 56 | if (i == (CGFloat)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 == (CGFloat)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 | if (prev) { 103 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 104 | make.width.equalTo(@(fixedItemLength)); 105 | if (i == (CGFloat)self.count - 1) {//last one 106 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 107 | } 108 | else { 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 | make.width.equalTo(@(fixedItemLength)); 115 | } 116 | }]; 117 | prev = v; 118 | } 119 | } 120 | else { 121 | MAS_VIEW *prev; 122 | for (int i = 0; i < self.count; i++) { 123 | MAS_VIEW *v = self[i]; 124 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 125 | if (prev) { 126 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 127 | make.height.equalTo(@(fixedItemLength)); 128 | if (i == (CGFloat)self.count - 1) {//last one 129 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 130 | } 131 | else { 132 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 133 | } 134 | } 135 | else {//first one 136 | make.top.equalTo(tempSuperView).offset(leadSpacing); 137 | make.height.equalTo(@(fixedItemLength)); 138 | } 139 | }]; 140 | prev = v; 141 | } 142 | } 143 | } 144 | 145 | - (MAS_VIEW *)mas_commonSuperviewOfViews 146 | { 147 | MAS_VIEW *commonSuperview = nil; 148 | MAS_VIEW *previousView = nil; 149 | for (id object in self) { 150 | if ([object isKindOfClass:[MAS_VIEW class]]) { 151 | MAS_VIEW *view = (MAS_VIEW *)object; 152 | if (previousView) { 153 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 154 | } else { 155 | commonSuperview = view; 156 | } 157 | previousView = view; 158 | } 159 | } 160 | 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."); 161 | return commonSuperview; 162 | } 163 | 164 | @end 165 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if TARGET_OS_IPHONE || TARGET_OS_TV 48 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 49 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 50 | @(NSLayoutAttributeTopMargin) : @"topMargin", 51 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 52 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 53 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 54 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 55 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 56 | #endif 57 | 58 | }; 59 | 60 | }); 61 | return descriptionMap; 62 | } 63 | 64 | 65 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 66 | static dispatch_once_t once; 67 | static NSDictionary *descriptionMap; 68 | dispatch_once(&once, ^{ 69 | #if TARGET_OS_IPHONE || TARGET_OS_TV 70 | descriptionMap = @{ 71 | @(MASLayoutPriorityDefaultHigh) : @"high", 72 | @(MASLayoutPriorityDefaultLow) : @"low", 73 | @(MASLayoutPriorityDefaultMedium) : @"medium", 74 | @(MASLayoutPriorityRequired) : @"required", 75 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 76 | }; 77 | #elif TARGET_OS_MAC 78 | descriptionMap = @{ 79 | @(MASLayoutPriorityDefaultHigh) : @"high", 80 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 81 | @(MASLayoutPriorityDefaultMedium) : @"medium", 82 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 83 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 84 | @(MASLayoutPriorityDefaultLow) : @"low", 85 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 86 | @(MASLayoutPriorityRequired) : @"required", 87 | }; 88 | #endif 89 | }); 90 | return descriptionMap; 91 | } 92 | 93 | #pragma mark - description override 94 | 95 | + (NSString *)descriptionForObject:(id)obj { 96 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 97 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 98 | } 99 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 100 | } 101 | 102 | - (NSString *)description { 103 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 104 | 105 | [description appendString:[self.class descriptionForObject:self]]; 106 | 107 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 108 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 109 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]]; 110 | } 111 | 112 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]]; 113 | 114 | if (self.secondItem) { 115 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 116 | } 117 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 118 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]]; 119 | } 120 | 121 | if (self.multiplier != 1) { 122 | [description appendFormat:@" * %g", self.multiplier]; 123 | } 124 | 125 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 126 | [description appendFormat:@" %g", self.constant]; 127 | } else { 128 | if (self.constant) { 129 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 130 | } 131 | } 132 | 133 | if (self.priority != MASLayoutPriorityRequired) { 134 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 135 | } 136 | 137 | [description appendString:@">"]; 138 | return description; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if TARGET_OS_IPHONE || TARGET_OS_TV 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 45 | 46 | #endif 47 | 48 | /** 49 | * a key to associate with this view 50 | */ 51 | @property (nonatomic, strong) id mas_key; 52 | 53 | /** 54 | * Finds the closest common superview between this view and another view 55 | * 56 | * @param view other view 57 | * 58 | * @return returns nil if common superview could not be found 59 | */ 60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 61 | 62 | /** 63 | * Creates a MASConstraintMaker with the callee view. 64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 65 | * 66 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 67 | * 68 | * @return Array of created MASConstraints 69 | */ 70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 71 | 72 | /** 73 | * Creates a MASConstraintMaker with the callee view. 74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 75 | * If an existing constraint exists then it will be updated instead. 76 | * 77 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 78 | * 79 | * @return Array of created/updated MASConstraints 80 | */ 81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 82 | 83 | /** 84 | * Creates a MASConstraintMaker with the callee view. 85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 86 | * All constraints previously installed for the view will be removed. 87 | * 88 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 89 | * 90 | * @return Array of created/updated MASConstraints 91 | */ 92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if TARGET_OS_IPHONE || TARGET_OS_TV 91 | 92 | - (MASViewAttribute *)mas_leftMargin { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 94 | } 95 | 96 | - (MASViewAttribute *)mas_rightMargin { 97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 98 | } 99 | 100 | - (MASViewAttribute *)mas_topMargin { 101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 102 | } 103 | 104 | - (MASViewAttribute *)mas_bottomMargin { 105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 106 | } 107 | 108 | - (MASViewAttribute *)mas_leadingMargin { 109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 110 | } 111 | 112 | - (MASViewAttribute *)mas_trailingMargin { 113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 114 | } 115 | 116 | - (MASViewAttribute *)mas_centerXWithinMargins { 117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 118 | } 119 | 120 | - (MASViewAttribute *)mas_centerYWithinMargins { 121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 122 | } 123 | 124 | #endif 125 | 126 | #pragma mark - associated properties 127 | 128 | - (id)mas_key { 129 | return objc_getAssociatedObject(self, @selector(mas_key)); 130 | } 131 | 132 | - (void)setMas_key:(id)key { 133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 134 | } 135 | 136 | #pragma mark - heirachy 137 | 138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 139 | MAS_VIEW *closestCommonSuperview = nil; 140 | 141 | MAS_VIEW *secondViewSuperview = view; 142 | while (!closestCommonSuperview && secondViewSuperview) { 143 | MAS_VIEW *firstViewSuperview = self; 144 | while (!closestCommonSuperview && firstViewSuperview) { 145 | if (secondViewSuperview == firstViewSuperview) { 146 | closestCommonSuperview = secondViewSuperview; 147 | } 148 | firstViewSuperview = firstViewSuperview.superview; 149 | } 150 | secondViewSuperview = secondViewSuperview.superview; 151 | } 152 | return closestCommonSuperview; 153 | } 154 | 155 | @end 156 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if TARGET_OS_IPHONE || TARGET_OS_TV 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 42 | 43 | #endif 44 | 45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 48 | 49 | @end 50 | 51 | #define MAS_ATTR_FORWARD(attr) \ 52 | - (MASViewAttribute *)attr { \ 53 | return [self mas_##attr]; \ 54 | } 55 | 56 | @implementation MAS_VIEW (MASShorthandAdditions) 57 | 58 | MAS_ATTR_FORWARD(top); 59 | MAS_ATTR_FORWARD(left); 60 | MAS_ATTR_FORWARD(bottom); 61 | MAS_ATTR_FORWARD(right); 62 | MAS_ATTR_FORWARD(leading); 63 | MAS_ATTR_FORWARD(trailing); 64 | MAS_ATTR_FORWARD(width); 65 | MAS_ATTR_FORWARD(height); 66 | MAS_ATTR_FORWARD(centerX); 67 | MAS_ATTR_FORWARD(centerY); 68 | MAS_ATTR_FORWARD(baseline); 69 | 70 | #if TARGET_OS_IPHONE || TARGET_OS_TV 71 | 72 | MAS_ATTR_FORWARD(leftMargin); 73 | MAS_ATTR_FORWARD(rightMargin); 74 | MAS_ATTR_FORWARD(topMargin); 75 | MAS_ATTR_FORWARD(bottomMargin); 76 | MAS_ATTR_FORWARD(leadingMargin); 77 | MAS_ATTR_FORWARD(trailingMargin); 78 | MAS_ATTR_FORWARD(centerXWithinMargins); 79 | MAS_ATTR_FORWARD(centerYWithinMargins); 80 | 81 | #endif 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 84 | return [self mas_attribute]; 85 | } 86 | 87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 88 | return [self mas_makeConstraints:block]; 89 | } 90 | 91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 92 | return [self mas_updateConstraints:block]; 93 | } 94 | 95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 96 | return [self mas_remakeConstraints:block]; 97 | } 98 | 99 | @end 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /QJSlideView/Masonry/README.md: -------------------------------------------------------------------------------- 1 | #Masonry [![Build Status](https://travis-ci.org/SnapKit/Masonry.svg?branch=master)](https://travis-ci.org/SnapKit/Masonry) [![Coverage Status](https://img.shields.io/coveralls/SnapKit/Masonry.svg?style=flat-square)](https://coveralls.io/r/SnapKit/Masonry) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 2 | 3 | **Masonry is still actively maintained, we are committed to fixing bugs and merging good quality PRs from the wider community. However if you're using Swift in your project, we recommend using [SnapKit](https://github.com/SnapKit/SnapKit) as it provides better type safety with a simpler API.** 4 | 5 | Masonry is a light-weight layout framework which wraps AutoLayout with a nicer syntax. Masonry has its own layout DSL which provides a chainable way of describing your NSLayoutConstraints which results in layout code that is more concise and readable. 6 | Masonry supports iOS and Mac OS X. 7 | 8 | For examples take a look at the **Masonry iOS Examples** project in the Masonry workspace. You will need to run `pod install` after downloading. 9 | 10 | ## What's wrong with NSLayoutConstraints? 11 | 12 | Under the hood Auto Layout is a powerful and flexible way of organising and laying out your views. However creating constraints from code is verbose and not very descriptive. 13 | Imagine a simple example in which you want to have a view fill its superview but inset by 10 pixels on every side 14 | ```obj-c 15 | UIView *superview = self; 16 | 17 | UIView *view1 = [[UIView alloc] init]; 18 | view1.translatesAutoresizingMaskIntoConstraints = NO; 19 | view1.backgroundColor = [UIColor greenColor]; 20 | [superview addSubview:view1]; 21 | 22 | UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10); 23 | 24 | [superview addConstraints:@[ 25 | 26 | //view1 constraints 27 | [NSLayoutConstraint constraintWithItem:view1 28 | attribute:NSLayoutAttributeTop 29 | relatedBy:NSLayoutRelationEqual 30 | toItem:superview 31 | attribute:NSLayoutAttributeTop 32 | multiplier:1.0 33 | constant:padding.top], 34 | 35 | [NSLayoutConstraint constraintWithItem:view1 36 | attribute:NSLayoutAttributeLeft 37 | relatedBy:NSLayoutRelationEqual 38 | toItem:superview 39 | attribute:NSLayoutAttributeLeft 40 | multiplier:1.0 41 | constant:padding.left], 42 | 43 | [NSLayoutConstraint constraintWithItem:view1 44 | attribute:NSLayoutAttributeBottom 45 | relatedBy:NSLayoutRelationEqual 46 | toItem:superview 47 | attribute:NSLayoutAttributeBottom 48 | multiplier:1.0 49 | constant:-padding.bottom], 50 | 51 | [NSLayoutConstraint constraintWithItem:view1 52 | attribute:NSLayoutAttributeRight 53 | relatedBy:NSLayoutRelationEqual 54 | toItem:superview 55 | attribute:NSLayoutAttributeRight 56 | multiplier:1 57 | constant:-padding.right], 58 | 59 | ]]; 60 | ``` 61 | Even with such a simple example the code needed is quite verbose and quickly becomes unreadable when you have more than 2 or 3 views. 62 | Another option is to use Visual Format Language (VFL), which is a bit less long winded. 63 | However the ASCII type syntax has its own pitfalls and its also a bit harder to animate as `NSLayoutConstraint constraintsWithVisualFormat:` returns an array. 64 | 65 | ## Prepare to meet your Maker! 66 | 67 | Heres the same constraints created using MASConstraintMaker 68 | 69 | ```obj-c 70 | UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10); 71 | 72 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) { 73 | make.top.equalTo(superview.mas_top).with.offset(padding.top); //with is an optional semantic filler 74 | make.left.equalTo(superview.mas_left).with.offset(padding.left); 75 | make.bottom.equalTo(superview.mas_bottom).with.offset(-padding.bottom); 76 | make.right.equalTo(superview.mas_right).with.offset(-padding.right); 77 | }]; 78 | ``` 79 | Or even shorter 80 | 81 | ```obj-c 82 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) { 83 | make.edges.equalTo(superview).with.insets(padding); 84 | }]; 85 | ``` 86 | 87 | Also note in the first example we had to add the constraints to the superview `[superview addConstraints:...`. 88 | Masonry however will automagically add constraints to the appropriate view. 89 | 90 | Masonry will also call `view1.translatesAutoresizingMaskIntoConstraints = NO;` for you. 91 | 92 | ## Not all things are created equal 93 | 94 | > `.equalTo` equivalent to **NSLayoutRelationEqual** 95 | 96 | > `.lessThanOrEqualTo` equivalent to **NSLayoutRelationLessThanOrEqual** 97 | 98 | > `.greaterThanOrEqualTo` equivalent to **NSLayoutRelationGreaterThanOrEqual** 99 | 100 | These three equality constraints accept one argument which can be any of the following: 101 | 102 | #### 1. MASViewAttribute 103 | 104 | ```obj-c 105 | make.centerX.lessThanOrEqualTo(view2.mas_left); 106 | ``` 107 | 108 | MASViewAttribute | NSLayoutAttribute 109 | ------------------------- | -------------------------- 110 | view.mas_left | NSLayoutAttributeLeft 111 | view.mas_right | NSLayoutAttributeRight 112 | view.mas_top | NSLayoutAttributeTop 113 | view.mas_bottom | NSLayoutAttributeBottom 114 | view.mas_leading | NSLayoutAttributeLeading 115 | view.mas_trailing | NSLayoutAttributeTrailing 116 | view.mas_width | NSLayoutAttributeWidth 117 | view.mas_height | NSLayoutAttributeHeight 118 | view.mas_centerX | NSLayoutAttributeCenterX 119 | view.mas_centerY | NSLayoutAttributeCenterY 120 | view.mas_baseline | NSLayoutAttributeBaseline 121 | 122 | #### 2. UIView/NSView 123 | 124 | if you want view.left to be greater than or equal to label.left : 125 | ```obj-c 126 | //these two constraints are exactly the same 127 | make.left.greaterThanOrEqualTo(label); 128 | make.left.greaterThanOrEqualTo(label.mas_left); 129 | ``` 130 | 131 | #### 3. NSNumber 132 | 133 | Auto Layout allows width and height to be set to constant values. 134 | if you want to set view to have a minimum and maximum width you could pass a number to the equality blocks: 135 | ```obj-c 136 | //width >= 200 && width <= 400 137 | make.width.greaterThanOrEqualTo(@200); 138 | make.width.lessThanOrEqualTo(@400) 139 | ``` 140 | 141 | However Auto Layout does not allow alignment attributes such as left, right, centerY etc to be set to constant values. 142 | So if you pass a NSNumber for these attributes Masonry will turn these into constraints relative to the view’s superview ie: 143 | ```obj-c 144 | //creates view.left = view.superview.left + 10 145 | make.left.lessThanOrEqualTo(@10) 146 | ``` 147 | 148 | Instead of using NSNumber, you can use primitives and structs to build your constraints, like so: 149 | ```obj-c 150 | make.top.mas_equalTo(42); 151 | make.height.mas_equalTo(20); 152 | make.size.mas_equalTo(CGSizeMake(50, 100)); 153 | make.edges.mas_equalTo(UIEdgeInsetsMake(10, 0, 10, 0)); 154 | make.left.mas_equalTo(view).mas_offset(UIEdgeInsetsMake(10, 0, 10, 0)); 155 | ``` 156 | 157 | By default, macros which support [autoboxing](https://en.wikipedia.org/wiki/Autoboxing#Autoboxing) are prefixed with `mas_`. Unprefixed versions are available by defining `MAS_SHORTHAND_GLOBALS` before importing Masonry. 158 | 159 | #### 4. NSArray 160 | 161 | An array of a mixture of any of the previous types 162 | ```obj-c 163 | make.height.equalTo(@[view1.mas_height, view2.mas_height]); 164 | make.height.equalTo(@[view1, view2]); 165 | make.left.equalTo(@[view1, @100, view3.right]); 166 | ```` 167 | 168 | ## Learn to prioritize 169 | 170 | > `.priority` allows you to specify an exact priority 171 | 172 | > `.priorityHigh` equivalent to **UILayoutPriorityDefaultHigh** 173 | 174 | > `.priorityMedium` is half way between high and low 175 | 176 | > `.priorityLow` equivalent to **UILayoutPriorityDefaultLow** 177 | 178 | Priorities are can be tacked on to the end of a constraint chain like so: 179 | ```obj-c 180 | make.left.greaterThanOrEqualTo(label.mas_left).with.priorityLow(); 181 | 182 | make.top.equalTo(label.mas_top).with.priority(600); 183 | ``` 184 | 185 | ## Composition, composition, composition 186 | 187 | Masonry also gives you a few convenience methods which create multiple constraints at the same time. These are called MASCompositeConstraints 188 | 189 | #### edges 190 | 191 | ```obj-c 192 | // make top, left, bottom, right equal view2 193 | make.edges.equalTo(view2); 194 | 195 | // make top = superview.top + 5, left = superview.left + 10, 196 | // bottom = superview.bottom - 15, right = superview.right - 20 197 | make.edges.equalTo(superview).insets(UIEdgeInsetsMake(5, 10, 15, 20)) 198 | ``` 199 | 200 | #### size 201 | 202 | ```obj-c 203 | // make width and height greater than or equal to titleLabel 204 | make.size.greaterThanOrEqualTo(titleLabel) 205 | 206 | // make width = superview.width + 100, height = superview.height - 50 207 | make.size.equalTo(superview).sizeOffset(CGSizeMake(100, -50)) 208 | ``` 209 | 210 | #### center 211 | ```obj-c 212 | // make centerX and centerY = button1 213 | make.center.equalTo(button1) 214 | 215 | // make centerX = superview.centerX - 5, centerY = superview.centerY + 10 216 | make.center.equalTo(superview).centerOffset(CGPointMake(-5, 10)) 217 | ``` 218 | 219 | You can chain view attributes for increased readability: 220 | 221 | ```obj-c 222 | // All edges but the top should equal those of the superview 223 | make.left.right.and.bottom.equalTo(superview); 224 | make.top.equalTo(otherView); 225 | ``` 226 | 227 | ## Hold on for dear life 228 | 229 | Sometimes you need modify existing constraints in order to animate or remove/replace constraints. 230 | In Masonry there are a few different approaches to updating constraints. 231 | 232 | #### 1. References 233 | You can hold on to a reference of a particular constraint by assigning the result of a constraint make expression to a local variable or a class property. 234 | You could also reference multiple constraints by storing them away in an array. 235 | 236 | ```obj-c 237 | // in public/private interface 238 | @property (nonatomic, strong) MASConstraint *topConstraint; 239 | 240 | ... 241 | 242 | // when making constraints 243 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) { 244 | self.topConstraint = make.top.equalTo(superview.mas_top).with.offset(padding.top); 245 | make.left.equalTo(superview.mas_left).with.offset(padding.left); 246 | }]; 247 | 248 | ... 249 | // then later you can call 250 | [self.topConstraint uninstall]; 251 | ``` 252 | 253 | #### 2. mas_updateConstraints 254 | Alternatively if you are only updating the constant value of the constraint you can use the convience method `mas_updateConstraints` instead of `mas_makeConstraints` 255 | 256 | ```obj-c 257 | // this is Apple's recommended place for adding/updating constraints 258 | // this method can get called multiple times in response to setNeedsUpdateConstraints 259 | // which can be called by UIKit internally or in your code if you need to trigger an update to your constraints 260 | - (void)updateConstraints { 261 | [self.growingButton mas_updateConstraints:^(MASConstraintMaker *make) { 262 | make.center.equalTo(self); 263 | make.width.equalTo(@(self.buttonSize.width)).priorityLow(); 264 | make.height.equalTo(@(self.buttonSize.height)).priorityLow(); 265 | make.width.lessThanOrEqualTo(self); 266 | make.height.lessThanOrEqualTo(self); 267 | }]; 268 | 269 | //according to apple super should be called at end of method 270 | [super updateConstraints]; 271 | } 272 | ``` 273 | 274 | ### 3. mas_remakeConstraints 275 | `mas_updateConstraints` is useful for updating a set of constraints, but doing anything beyond updating constant values can get exhausting. That's where `mas_remakeConstraints` comes in. 276 | 277 | `mas_remakeConstraints` is similar to `mas_updateConstraints`, but instead of updating constant values, it will remove all of its contraints before installing them again. This lets you provide different constraints without having to keep around references to ones which you want to remove. 278 | 279 | ```obj-c 280 | - (void)changeButtonPosition { 281 | [self.button mas_remakeConstraints:^(MASConstraintMaker *make) { 282 | make.size.equalTo(self.buttonSize); 283 | 284 | if (topLeft) { 285 | make.top.and.left.offset(10); 286 | } else { 287 | make.bottom.and.right.offset(-10); 288 | } 289 | }]; 290 | } 291 | ``` 292 | 293 | You can find more detailed examples of all three approaches in the **Masonry iOS Examples** project. 294 | 295 | ## When the ^&*!@ hits the fan! 296 | 297 | Laying out your views doesn't always goto plan. So when things literally go pear shaped, you don't want to be looking at console output like this: 298 | 299 | ```obj-c 300 | Unable to simultaneously satisfy constraints.....blah blah blah.... 301 | ( 302 | "=5000)]>", 303 | "", 304 | "", 305 | "" 306 | ) 307 | 308 | Will attempt to recover by breaking constraint 309 | =5000)]> 310 | ``` 311 | 312 | Masonry adds a category to NSLayoutConstraint which overrides the default implementation of `- (NSString *)description`. 313 | Now you can give meaningful names to views and constraints, and also easily pick out the constraints created by Masonry. 314 | 315 | which means your console output can now look like this: 316 | 317 | ```obj-c 318 | Unable to simultaneously satisfy constraints......blah blah blah.... 319 | ( 320 | "", 321 | "= 5000>", 322 | "", 323 | "" 324 | ) 325 | 326 | Will attempt to recover by breaking constraint 327 | = 5000> 328 | ``` 329 | 330 | For an example of how to set this up take a look at the **Masonry iOS Examples** project in the Masonry workspace. 331 | 332 | ## Where should I create my constraints? 333 | 334 | ```objc 335 | @implementation DIYCustomView 336 | 337 | - (id)init { 338 | self = [super init]; 339 | if (!self) return nil; 340 | 341 | // --- Create your views here --- 342 | self.button = [[UIButton alloc] init]; 343 | 344 | return self; 345 | } 346 | 347 | // tell UIKit that you are using AutoLayout 348 | + (BOOL)requiresConstraintBasedLayout { 349 | return YES; 350 | } 351 | 352 | // this is Apple's recommended place for adding/updating constraints 353 | - (void)updateConstraints { 354 | 355 | // --- remake/update constraints here 356 | [self.button remakeConstraints:^(MASConstraintMaker *make) { 357 | make.width.equalTo(@(self.buttonSize.width)); 358 | make.height.equalTo(@(self.buttonSize.height)); 359 | }]; 360 | 361 | //according to apple super should be called at end of method 362 | [super updateConstraints]; 363 | } 364 | 365 | - (void)didTapButton:(UIButton *)button { 366 | // --- Do your changes ie change variables that affect your layout etc --- 367 | self.buttonSize = CGSize(200, 200); 368 | 369 | // tell constraints they need updating 370 | [self setNeedsUpdateConstraints]; 371 | } 372 | 373 | @end 374 | ``` 375 | 376 | ## Installation 377 | Use the [orsome](http://www.youtube.com/watch?v=YaIZF8uUTtk) [CocoaPods](http://github.com/CocoaPods/CocoaPods). 378 | 379 | In your Podfile 380 | >`pod 'Masonry'` 381 | 382 | If you want to use masonry without all those pesky 'mas_' prefixes. Add #define MAS_SHORTHAND to your prefix.pch before importing Masonry 383 | >`#define MAS_SHORTHAND` 384 | 385 | Get busy Masoning 386 | >`#import "Masonry.h"` 387 | 388 | ## Code Snippets 389 | 390 | Copy the included code snippets to ``~/Library/Developer/Xcode/UserData/CodeSnippets`` to write your masonry blocks at lightning speed! 391 | 392 | `mas_make` -> `[ mas_makeConstraints:^(MASConstraintMaker *make){}];` 393 | 394 | `mas_update` -> `[ mas_updateConstraints:^(MASConstraintMaker *make){}];` 395 | 396 | `mas_remake` -> `[ mas_remakeConstraints:^(MASConstraintMaker *make){}];` 397 | 398 | ## Features 399 | * Not limited to subset of Auto Layout. Anything NSLayoutConstraint can do, Masonry can do too! 400 | * Great debug support, give your views and constraints meaningful names. 401 | * Constraints read like sentences. 402 | * No crazy macro magic. Masonry won't pollute the global namespace with macros. 403 | * Not string or dictionary based and hence you get compile time checking. 404 | 405 | ## TODO 406 | * Eye candy 407 | * Mac example project 408 | * More tests and examples 409 | 410 | -------------------------------------------------------------------------------- /QJSlideView/NavigationViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationViewController.h 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NavigationViewController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /QJSlideView/NavigationViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationViewController.m 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import "NavigationViewController.h" 10 | 11 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 12 | 13 | @interface NavigationViewController () 14 | 15 | @end 16 | 17 | @implementation NavigationViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view. 22 | [self.navigationBar setBarTintColor:UIColorFromRGB(0x5c8aea)]; 23 | [self.navigationBar setTranslucent:NO]; 24 | [self.navigationBar setTintColor:[UIColor whiteColor]]; 25 | [self.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil]]; 26 | 27 | // 去掉导航分割线 28 | [self.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; 29 | [self.navigationBar setShadowImage:[[UIImage alloc] init]]; 30 | 31 | } 32 | 33 | - (void)didReceiveMemoryWarning { 34 | [super didReceiveMemoryWarning]; 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | /* 39 | #pragma mark - Navigation 40 | 41 | // In a storyboard-based application, you will often want to do a little preparation before navigation 42 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 43 | // Get the new view controller using [segue destinationViewController]. 44 | // Pass the selected object to the new view controller. 45 | } 46 | */ 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /QJSlideView/QJBigScrollView.h: -------------------------------------------------------------------------------- 1 | // 2 | // QJBigScrollView.h 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void(^BgScrollViewBlock)(NSInteger index); 12 | @interface QJBigScrollView : UIScrollView 13 | 14 | 15 | - (id)initWithcontroller:(UIViewController *)VC TitleArr:(NSArray *)titleArr; 16 | 17 | -(void)setBgScrollViewContentOffset:(NSInteger)index; 18 | 19 | @property(nonatomic, copy)BgScrollViewBlock Bgbolck; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /QJSlideView/QJBigScrollView.m: -------------------------------------------------------------------------------- 1 | // 2 | // QJBigScrollView.m 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import "QJBigScrollView.h" 10 | #import "Masonry.h" 11 | #import "QJsampleView.h" 12 | #import "Helper.h" 13 | 14 | #define Screen_Width ([UIScreen mainScreen].bounds.size.width) 15 | #define Screen_Height ([UIScreen mainScreen].bounds.size.height) 16 | #define BaseTag 20000 17 | 18 | 19 | @interface QJBigScrollView () 20 | 21 | @property(nonatomic, strong)NSArray *titleArr; 22 | 23 | @property(nonatomic, strong)NSMutableArray *reuseViewArr; 24 | 25 | @property (nonatomic, assign) CGFloat offset; 26 | 27 | @end 28 | 29 | @implementation QJBigScrollView{ 30 | CGFloat contentOff_X; 31 | UIView * loadingView; 32 | } 33 | 34 | 35 | /* 36 | // Only override drawRect: if you perform custom drawing. 37 | // An empty implementation adversely affects performance during animation. 38 | - (void)drawRect:(CGRect)rect { 39 | // Drawing code 40 | } 41 | */ 42 | 43 | -(id)initWithcontroller:(UIViewController *)VC TitleArr:(NSArray *)titleArr; 44 | { 45 | self = [super init]; 46 | if (self) { 47 | self.titleArr = titleArr; 48 | self.frame = [self getViewFrame]; 49 | self.reuseViewArr = [[NSMutableArray alloc] initWithCapacity:0]; 50 | self.pagingEnabled = YES; 51 | self.showsHorizontalScrollIndicator = NO; 52 | self.showsVerticalScrollIndicator = NO; 53 | self.bounces = NO; 54 | self.delegate = self; 55 | self.contentSize = CGSizeMake(Screen_Width * self.titleArr.count, Screen_Height - 44); 56 | [VC.view addSubview:self]; 57 | [self confingSubViews]; 58 | 59 | } 60 | return self; 61 | } 62 | 63 | -(CGRect)getViewFrame 64 | { 65 | CGRect frame = CGRectZero; 66 | frame.size.height = Screen_Height - 44; 67 | frame.size.width = Screen_Width; 68 | frame.origin.x = 0; 69 | frame.origin.y = 44; 70 | return frame; 71 | } 72 | 73 | -(void)confingSubViews 74 | { 75 | NSInteger i = 0; 76 | for (i = 0; i < 3; i++) { 77 | QJsampleView *view = [[QJsampleView alloc] initWithFrame:CGRectMake(i * Screen_Width, 0, Screen_Width, Screen_Height - 44) Title:self.titleArr[i]]; 78 | // 添加子视图到scrollview 79 | [self addSubview:view]; 80 | // 添加view到托管的重用数组 81 | [self.reuseViewArr addObject:view]; 82 | } 83 | } 84 | 85 | 86 | -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { 87 | 88 | self.offset = scrollView.contentOffset.x; 89 | 90 | } 91 | 92 | -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 93 | { 94 | contentOff_X = scrollView.contentOffset.x; 95 | NSInteger index = contentOff_X/Screen_Width; 96 | __weak typeof(self) weak = self; 97 | if (contentOff_X < 0 || contentOff_X > Screen_Width * (self.titleArr.count - 1)) { 98 | 99 | }else{ 100 | if (contentOff_X > self.offset){ 101 | [self initRightView:index Complete:^(QJsampleView *view, NSInteger index) { 102 | [weak reflashUI:view Index:index]; 103 | }]; 104 | }else if (contentOff_X < self.offset){ 105 | [self initRightView:index Complete:^(QJsampleView *view, NSInteger index) { 106 | [weak reflashUI:view Index:index]; 107 | }]; 108 | } 109 | if (self.Bgbolck) { 110 | self.Bgbolck(index); 111 | } 112 | 113 | } 114 | } 115 | 116 | -(void)setBgScrollViewContentOffset:(NSInteger)index 117 | { 118 | [self setContentOffset:CGPointMake(Screen_Width *index, 0)]; 119 | __weak typeof(self) weak = self; 120 | 121 | if (index > 1) { 122 | [self initRightView:index Complete:^(QJsampleView *view, NSInteger index) { 123 | [weak reflashUI:view Index:index]; 124 | }]; 125 | } 126 | if (index <= 1) { 127 | [self initLeftView:index Complete:^(QJsampleView *view, NSInteger index) { 128 | [weak reflashUI:view Index:index]; 129 | }]; 130 | } 131 | } 132 | 133 | -(void)removeLeftView:(void(^)(QJsampleView *view))completion 134 | { 135 | QJsampleView *View = [self getReuseViewFromArr:0]; 136 | if (completion) { 137 | completion(View); 138 | } 139 | } 140 | 141 | -(void)removeRightView:(void(^)(QJsampleView *view))completion 142 | { 143 | QJsampleView *View = [self getReuseViewFromArr:2]; 144 | if (completion) { 145 | completion(View); 146 | } 147 | } 148 | - (void)initRightView:(NSInteger)index Complete:(void(^)(QJsampleView *view, NSInteger index))complete 149 | { 150 | [self removeLeftView:^(QJsampleView *view) { 151 | [self.reuseViewArr removeObject:view]; 152 | [view setFrame:CGRectMake(Screen_Width *index, 0, Screen_Width, Screen_Height - 44)]; 153 | [self.reuseViewArr addObject:view]; 154 | if (complete) { 155 | complete(view,index); 156 | } 157 | }]; 158 | } 159 | 160 | - (void)initLeftView:(NSInteger)index Complete:(void(^)(QJsampleView *view, NSInteger index))complete 161 | { 162 | [self removeRightView:^(QJsampleView *view) { 163 | [self.reuseViewArr removeObject:view]; 164 | [view setFrame:CGRectMake(Screen_Width *index, 0, Screen_Width, Screen_Height - 44)]; 165 | [self.reuseViewArr addObject:view]; 166 | if (complete) { 167 | complete(view,index); 168 | } 169 | }]; 170 | } 171 | 172 | -(QJsampleView *)getReuseViewFromArr:(NSInteger)index 173 | { 174 | if (self.reuseViewArr[index] == nil) { 175 | QJsampleView *view = [[QJsampleView alloc] initWithFrame:CGRectMake(index * Screen_Width, 0, Screen_Width, Screen_Height - 44) Title:self.titleArr[index]]; 176 | [self.reuseViewArr insertObject:view atIndex:index]; 177 | return view; 178 | } 179 | return self.reuseViewArr[index]; 180 | } 181 | 182 | /** 183 | * 刷新视图的UI的方法 184 | */ 185 | -(void)reflashUI:(QJsampleView *)view Index:(NSInteger)index 186 | { 187 | loadingView = [Helper initLoadingViewInView]; 188 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 189 | // 处理耗时操作的代码块... 190 | 191 | dispatch_async(dispatch_get_main_queue(), ^{ 192 | //通知主线程刷新 193 | view.title = self.titleArr[index]; 194 | [view reloadData]; 195 | 196 | [loadingView removeFromSuperview]; 197 | loadingView = nil; 198 | 199 | }); 200 | 201 | }); 202 | } 203 | 204 | -(void)delayMethod 205 | { 206 | 207 | } 208 | 209 | @end 210 | -------------------------------------------------------------------------------- /QJSlideView/QJSlideButtonView.h: -------------------------------------------------------------------------------- 1 | // 2 | // QJSlideButtonView.h 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void(^SBViewBlock)(NSInteger index); 12 | 13 | @interface QJSlideButtonView : UIScrollView 14 | 15 | @property(nonatomic, strong)NSArray *titleArr; 16 | 17 | - (id)initWithcontroller:(UIViewController *)VC TitleArr:(NSArray *)titleArr; 18 | 19 | -(void)setSBScrollViewContentOffset:(NSInteger)index; 20 | 21 | @property(nonatomic, copy)SBViewBlock sbBlock; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /QJSlideView/QJSlideButtonView.m: -------------------------------------------------------------------------------- 1 | // 2 | // QJSlideButtonView.m 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import "QJSlideButtonView.h" 10 | #import "Masonry.h" 11 | 12 | /** 13 | * screen -->> width/height 14 | */ 15 | #define Screen_Width ([UIScreen mainScreen].bounds.size.width) 16 | #define Screen_Height ([UIScreen mainScreen].bounds.size.height) 17 | 18 | #define ButtonSpace Screen_Width * 20/414 19 | #define BaseTag 10000 20 | 21 | #define TITLEFONT 20*Screen_Height/736 22 | 23 | 24 | 25 | /** 26 | * clolor 27 | */ 28 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 29 | 30 | 31 | @interface QJSlideButtonView() 32 | 33 | @property(nonatomic, strong)UIImageView *lineView; 34 | 35 | @property(nonatomic, strong)NSMutableArray *titleContentOrigin_X_Arr; 36 | 37 | @property(nonatomic, strong)NSMutableArray *titleContentSize_Width_Arr; 38 | 39 | 40 | @end 41 | 42 | @implementation QJSlideButtonView{ 43 | NSInteger BeforeButtonTag; 44 | NSInteger contentSize_width; 45 | NSInteger centerWordLocation_X; 46 | } 47 | 48 | /* 49 | // Only override drawRect: if you perform custom drawing. 50 | // An empty implementation adversely affects performance during animation. 51 | - (void)drawRect:(CGRect)rect { 52 | // Drawing code 53 | } 54 | */ 55 | 56 | - (id)initWithcontroller:(UIViewController *)VC TitleArr:(NSArray *)titleArr 57 | { 58 | self = [super init]; 59 | if (self) { 60 | self.frame = [self getViewFrame]; 61 | self.backgroundColor = UIColorFromRGB(0xf5f5f5); 62 | self.pagingEnabled = NO; 63 | self.showsHorizontalScrollIndicator = NO; 64 | self.showsVerticalScrollIndicator = NO; 65 | [VC.view addSubview:self]; 66 | self.titleContentOrigin_X_Arr = [[NSMutableArray alloc] initWithCapacity:0]; 67 | self.titleContentSize_Width_Arr = [[NSMutableArray alloc] initWithCapacity:0]; 68 | self.titleArr = titleArr; 69 | [self confingSubviews]; 70 | [self locateCenterWordPosition]; 71 | } 72 | return self; 73 | } 74 | 75 | -(CGRect)getViewFrame 76 | { 77 | CGRect frame = CGRectZero; 78 | frame.size.height = 44; 79 | frame.size.width = Screen_Width; 80 | frame.origin.x = 0; 81 | frame.origin.y = 0; 82 | return frame; 83 | } 84 | 85 | -(void)confingSubviews 86 | { 87 | float contentWidth = 0.0; 88 | float Origin_X = ButtonSpace/2; 89 | for (int i = 0; i < self.titleArr.count; i ++) { 90 | UIButton *titleBt = [UIButton buttonWithType:UIButtonTypeCustom]; 91 | NSString *title = [self.titleArr objectAtIndex:i]; 92 | [titleBt setTag:BaseTag + i]; 93 | if (i == 0) { 94 | titleBt.selected = YES; 95 | BeforeButtonTag = i; 96 | } 97 | [titleBt setTitle:title forState:UIControlStateNormal]; 98 | titleBt.titleLabel.font = [UIFont systemFontOfSize:TITLEFONT]; 99 | [titleBt setTitleColor:UIColorFromRGB(0x868686) forState:UIControlStateNormal]; 100 | [titleBt setTitleColor:UIColorFromRGB(0x5c8aea) forState:UIControlStateSelected]; 101 | [titleBt addTarget:self action:@selector(selectType:) forControlEvents:UIControlEventTouchUpInside]; 102 | [titleBt setBackgroundColor:UIColorFromRGB(0xf5f5f5)]; 103 | 104 | NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:TITLEFONT + 1]}; 105 | CGSize textSize = [title boundingRectWithSize:CGSizeMake(ButtonSpace*11, 44) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size; 106 | [self addSubview:titleBt]; 107 | 108 | [titleBt mas_makeConstraints:^(MASConstraintMaker *make) { 109 | make.left.mas_equalTo(self).offset(Origin_X); 110 | make.top.equalTo(self.mas_top); 111 | make.height.mas_equalTo(44-5); 112 | make.width.mas_equalTo(textSize.width); 113 | }]; 114 | [self.titleContentOrigin_X_Arr addObject:@(Origin_X)]; 115 | contentWidth += (textSize.width + ButtonSpace); 116 | Origin_X += textSize.width + ButtonSpace; 117 | [self.titleContentSize_Width_Arr addObject:@(textSize.width)]; 118 | } 119 | contentSize_width = contentWidth + ButtonSpace/2; 120 | self.contentSize = CGSizeMake(contentSize_width, 44); 121 | 122 | [self addSubview:self.lineView]; 123 | self.lineView.frame = CGRectMake([self.titleContentOrigin_X_Arr[0] floatValue], 44 - 3, [self.titleContentSize_Width_Arr[0] floatValue], 3); 124 | 125 | } 126 | 127 | -(UIImageView *)lineView 128 | { 129 | if (_lineView == nil) { 130 | _lineView = [[UIImageView alloc] init]; 131 | _lineView.backgroundColor = UIColorFromRGB(0x5c8aea); 132 | } 133 | return _lineView; 134 | } 135 | 136 | - (void)selectType:(UIButton *)bt 137 | { 138 | __weak typeof(self) weakself = self; 139 | CGFloat Origin_X = [self.titleContentOrigin_X_Arr[bt.tag - BaseTag] floatValue]; 140 | if (BeforeButtonTag != bt.tag - BaseTag) { 141 | [self changeBeforeBtStatus:^{ 142 | if (BeforeButtonTag < bt.tag - BaseTag) { 143 | /** 144 | * 整体往左滚 145 | */ 146 | if (Origin_X < centerWordLocation_X) { 147 | //no any reaction 148 | NSLog(@"no any reaction"); 149 | }else if (self.contentSize.width - Origin_X < Screen_Width - centerWordLocation_X){ 150 | [self setContentOffset:CGPointMake(self.contentSize.width - Screen_Width, 0) animated:YES]; 151 | }else{ 152 | [self setContentOffset:CGPointMake(Origin_X -centerWordLocation_X, 0) animated:YES]; 153 | } 154 | 155 | }else{ 156 | /** 157 | * 整体往右滚 158 | */ 159 | if (Origin_X < centerWordLocation_X) { 160 | [self setContentOffset:CGPointMake(0, 0) animated:YES]; 161 | }else if (contentSize_width - Origin_X - 2 *ButtonSpace < centerWordLocation_X){ 162 | // no any reaction 163 | NSLog(@"no any reaction"); 164 | }else{ 165 | [self setContentOffset:CGPointMake(Origin_X - centerWordLocation_X, 0) animated:YES]; 166 | } 167 | } 168 | NSInteger index = bt.tag - BaseTag; 169 | bt.selected = !bt.selected; 170 | [weakself startAnimation:index]; 171 | }]; 172 | if (self.sbBlock) { 173 | self.sbBlock(bt.tag - BaseTag); 174 | } 175 | 176 | }else{ 177 | return; 178 | } 179 | } 180 | 181 | -(void)startAnimation:(NSInteger)index 182 | { 183 | [UIView animateWithDuration:0.2 animations:^{ 184 | self.lineView.frame = CGRectMake([self.titleContentOrigin_X_Arr[index] floatValue], 44 - 3, [self.titleContentSize_Width_Arr[index] floatValue], 3); 185 | NSLog(@"当前分类--->>%@",self.titleArr[index]); 186 | } completion:^(BOOL finished) { 187 | BeforeButtonTag = index; 188 | }]; 189 | 190 | } 191 | 192 | -(void)locateCenterWordPosition 193 | { 194 | for (int i = 0; i < self.titleContentOrigin_X_Arr.count; i ++) { 195 | NSInteger origin_x = [self.titleContentOrigin_X_Arr[i] integerValue]; 196 | NSInteger contentWidth = [self.titleContentSize_Width_Arr[i] integerValue]; 197 | if (origin_x < Screen_Width/2 && origin_x + contentWidth > Screen_Width/2) { 198 | centerWordLocation_X = origin_x; 199 | } 200 | } 201 | } 202 | 203 | - (void)changeBeforeBtStatus:(void(^)())block 204 | { 205 | UIButton *beforeBt = (UIButton *)[self viewWithTag:BaseTag + BeforeButtonTag]; 206 | beforeBt.selected = !beforeBt.selected; 207 | if (block) { 208 | block(); 209 | } 210 | } 211 | 212 | -(void)setSBScrollViewContentOffset:(NSInteger)index 213 | { 214 | CGFloat Origin_X = [self.titleContentOrigin_X_Arr[index] floatValue]; 215 | UIButton *nowBt = (UIButton *)[self viewWithTag:BaseTag + index]; 216 | 217 | if (BeforeButtonTag < nowBt.tag - BaseTag) { 218 | /** 219 | * 整体往左滚 220 | */ 221 | if (Origin_X < centerWordLocation_X) { 222 | //no any reaction 223 | NSLog(@"no any reaction"); 224 | }else if (self.contentSize.width - Origin_X < Screen_Width - centerWordLocation_X){ 225 | [self setContentOffset:CGPointMake(self.contentSize.width - Screen_Width, 0) animated:YES]; 226 | }else{ 227 | [self setContentOffset:CGPointMake(Origin_X -centerWordLocation_X, 0) animated:YES]; 228 | } 229 | 230 | }else{ 231 | /** 232 | * 整体往右滚 233 | */ 234 | if (Origin_X < centerWordLocation_X) { 235 | [self setContentOffset:CGPointMake(0, 0) animated:YES]; 236 | }else if (contentSize_width - Origin_X - 2 *ButtonSpace < centerWordLocation_X){ 237 | // no any reaction 238 | NSLog(@"no any reaction"); 239 | }else{ 240 | [self setContentOffset:CGPointMake(Origin_X - centerWordLocation_X, 0) animated:YES]; 241 | } 242 | } 243 | __weak typeof(self) weakself = self; 244 | [self changeBeforeBtStatus:^{ 245 | UIButton *nowBt = (UIButton *)[self viewWithTag:BaseTag + index]; 246 | nowBt.selected = !nowBt.selected; 247 | [weakself startAnimation:index]; 248 | }]; 249 | } 250 | 251 | @end 252 | -------------------------------------------------------------------------------- /QJSlideView/QJsampleView.h: -------------------------------------------------------------------------------- 1 | // 2 | // QJsampleView.h 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/12. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface QJsampleView : UIView 12 | 13 | -(instancetype)initWithFrame:(CGRect)frame Title:(NSString *)title; 14 | 15 | @property(nonatomic, copy)NSString *title; 16 | 17 | - (void)reloadData; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /QJSlideView/QJsampleView.m: -------------------------------------------------------------------------------- 1 | // 2 | // QJsampleView.m 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/12. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import "QJsampleView.h" 10 | #define Screen_Width ([UIScreen mainScreen].bounds.size.width) 11 | #define Screen_Height ([UIScreen mainScreen].bounds.size.height) 12 | 13 | @interface QJsampleView () 14 | 15 | /** 16 | * mytableView 可以根据自己需求替换成自己的视图. 17 | */ 18 | @property(nonatomic, strong)UITableView *mytableView; 19 | 20 | @end 21 | 22 | @implementation QJsampleView 23 | 24 | /* 25 | // Only override drawRect: if you perform custom drawing. 26 | // An empty implementation adversely affects performance during animation. 27 | - (void)drawRect:(CGRect)rect { 28 | // Drawing code 29 | } 30 | */ 31 | 32 | -(instancetype)initWithFrame:(CGRect)frame Title:(NSString *)title 33 | { 34 | self = [super initWithFrame:frame]; 35 | if (self) { 36 | self.title = title; 37 | [self confingSubViews]; 38 | } 39 | return self; 40 | } 41 | 42 | - (void)confingSubViews 43 | { 44 | [self addSubview:self.mytableView]; 45 | } 46 | 47 | 48 | -(UITableView *)mytableView 49 | { 50 | if (_mytableView != nil) { 51 | return _mytableView; 52 | } 53 | _mytableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height - 44) style:UITableViewStylePlain]; 54 | _mytableView.delegate = self; 55 | _mytableView.dataSource = self; 56 | _mytableView.showsHorizontalScrollIndicator = NO; 57 | _mytableView.showsVerticalScrollIndicator = NO; 58 | _mytableView.layer.cornerRadius = 10; 59 | _mytableView.backgroundColor = [UIColor whiteColor]; 60 | return _mytableView; 61 | } 62 | 63 | 64 | -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 65 | { 66 | return 1; 67 | } 68 | 69 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 70 | { 71 | return 20; 72 | } 73 | 74 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 75 | { 76 | return 30; 77 | } 78 | 79 | -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 80 | { 81 | static NSString *identifier = @"statusCell"; 82 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; 83 | if (cell == nil) { 84 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; 85 | // cell.selectionStyle = UITableViewCellSelectionStyleGray; 86 | } 87 | 88 | for (UIView *view in cell.contentView.subviews) { 89 | [view removeFromSuperview]; 90 | } 91 | if (indexPath.row%2 == 0) { 92 | cell.backgroundColor = [UIColor lightGrayColor]; 93 | } 94 | cell.textLabel.text = self.title; 95 | cell.textLabel.font = [UIFont systemFontOfSize:15]; 96 | 97 | return cell; 98 | 99 | } 100 | 101 | /** 102 | * 刷新数据 103 | */ 104 | - (void)reloadData 105 | { 106 | [self.mytableView reloadData]; 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /QJSlideView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /QJSlideView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "QJSlideButtonView.h" 11 | #import "QJBigScrollView.h" 12 | 13 | @interface ViewController () 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view, typically from a nib. 22 | self.title = @"QJSlideView"; 23 | 24 | [self confingSlideButtonView]; 25 | } 26 | 27 | - (void)confingSlideButtonView 28 | { 29 | NSArray *titleArr = @[@"英语",@"数学",@"语文",@"历史",@"地理",@"思想政治",@"化学",@"物理",@"体育",@"生物",@"音乐",@"美术"]; 30 | 31 | QJSlideButtonView *s = [[QJSlideButtonView alloc] initWithcontroller:self TitleArr:titleArr]; 32 | QJBigScrollView *b = [[QJBigScrollView alloc] initWithcontroller:self TitleArr:titleArr]; 33 | 34 | __weak typeof(s) Sweak = s; 35 | __weak typeof(b) Bweak = b; 36 | b.Bgbolck = ^(NSInteger index){ 37 | [Sweak setSBScrollViewContentOffset:index]; 38 | }; 39 | s.sbBlock = ^(NSInteger index){ 40 | [Bweak setBgScrollViewContentOffset:index]; 41 | }; 42 | } 43 | 44 | 45 | 46 | - (void)didReceiveMemoryWarning { 47 | [super didReceiveMemoryWarning]; 48 | // Dispose of any resources that can be recreated. 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /QJSlideView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // QJSlideView 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. 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 | -------------------------------------------------------------------------------- /QJSlideViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /QJSlideViewTests/QJSlideViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // QJSlideViewTests.m 3 | // QJSlideViewTests 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface QJSlideViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation QJSlideViewTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /QJSlideViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /QJSlideViewUITests/QJSlideViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // QJSlideViewUITests.m 3 | // QJSlideViewUITests 4 | // 5 | // Created by Justin on 16/3/10. 6 | // Copyright © 2016年 Justin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface QJSlideViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation QJSlideViewUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // 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. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | QJSlideView 2 | =================================== 3 | 仿网易/今日头条滑动视图 4 | 5 | 6 | 重点:View重用 / 滑动位置计算. 7 | ----------------------------------- 8 | 滑动过程中对scrollView上的视图进行重用,并且保持当前选中的类型永远在中间显示,通过block回调进行两个视图之间的消息传递. 9 | 10 | 11 | ### 支持滑动大scrollView和点击小的分类scrollView刷新当前页面信息 12 | 13 | ### About 14 | **QJSlideView** 在滑动过程中会对大scrollView上的视图进行重用,并且在没有滑动到边界时,滑块始终保持在屏幕中间位置.通过Block回调对当前正在显示的分类进行数据刷新. 15 | 16 | 解决屏幕适配问题,现在适配iPhone的各种机型 17 | 18 | ### Installation Instructions: 19 | 20 | 1. Copy the 'QJSlideView' folder into your Xcode project. The following files will be added: 21 | 2. #import "QJSlideButtonView.h" 22 | 3. #import "QJBigScrollView.h" 23 | 24 | 25 | ### details 26 | 27 | NSArray *titleArr = @[@"英语",@"数学",@"语文",@"历史",@"地理",@"思想政治",@"化学",@"物理",@"体育",@"生物",@"音乐",@"美术"]; 28 | 29 | QJSlideButtonView *s = [[QJSlideButtonView alloc] initWithcontroller:self TitleArr:titleArr]; 30 | QJBigScrollView *b = [[QJBigScrollView alloc] initWithcontroller:self TitleArr:titleArr]; 31 | 32 | __weak typeof(s) Sweak = s; 33 | __weak typeof(b) Bweak = b; 34 | b.Bgbolck = ^(NSInteger index){ 35 | [Sweak setSBScrollViewContentOffset:index]; 36 | }; 37 | s.sbBlock = ^(NSInteger index){ 38 | [Bweak setBgScrollViewContentOffset:index]; 39 | }; 40 | 41 | ### 感谢 42 | Masonry 43 | 44 | 45 | --------------------------------------------------------------------------------