├── .DS_Store ├── .gitignore ├── 1.png ├── 2.png ├── EasyAutoLayout ├── .DS_Store ├── EasyAutoLayout.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── EasyAutoLayout │ ├── .DS_Store │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Extension │ ├── RT_LayoutAttributes.swift │ └── UIView+AutoLayout.swift │ ├── Info.plist │ └── ViewController.swift ├── LICENSE └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeXiaoQiang/EasyAutoLayout-swift/9055fa264cbc260db0554365c82dfae9548198a0/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/screenshots 64 | -------------------------------------------------------------------------------- /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeXiaoQiang/EasyAutoLayout-swift/9055fa264cbc260db0554365c82dfae9548198a0/1.png -------------------------------------------------------------------------------- /2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeXiaoQiang/EasyAutoLayout-swift/9055fa264cbc260db0554365c82dfae9548198a0/2.png -------------------------------------------------------------------------------- /EasyAutoLayout/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeXiaoQiang/EasyAutoLayout-swift/9055fa264cbc260db0554365c82dfae9548198a0/EasyAutoLayout/.DS_Store -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9D1EF47B1C9010960046BCD0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1EF47A1C9010960046BCD0 /* AppDelegate.swift */; }; 11 | 9D1EF47D1C9010960046BCD0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1EF47C1C9010960046BCD0 /* ViewController.swift */; }; 12 | 9D1EF4801C9010960046BCD0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D1EF47E1C9010960046BCD0 /* Main.storyboard */; }; 13 | 9D1EF4821C9010960046BCD0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9D1EF4811C9010960046BCD0 /* Assets.xcassets */; }; 14 | 9D1EF4851C9010960046BCD0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D1EF4831C9010960046BCD0 /* LaunchScreen.storyboard */; }; 15 | 9D1EF48E1C9010D80046BCD0 /* UIView+AutoLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1EF48D1C9010D80046BCD0 /* UIView+AutoLayout.swift */; }; 16 | 9D1EF4901C9011A70046BCD0 /* RT_LayoutAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1EF48F1C9011A70046BCD0 /* RT_LayoutAttributes.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 9D1EF4771C9010960046BCD0 /* EasyAutoLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EasyAutoLayout.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 9D1EF47A1C9010960046BCD0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 9D1EF47C1C9010960046BCD0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 23 | 9D1EF47F1C9010960046BCD0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 24 | 9D1EF4811C9010960046BCD0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 9D1EF4841C9010960046BCD0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 26 | 9D1EF4861C9010960046BCD0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 9D1EF48D1C9010D80046BCD0 /* UIView+AutoLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+AutoLayout.swift"; sourceTree = ""; }; 28 | 9D1EF48F1C9011A70046BCD0 /* RT_LayoutAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RT_LayoutAttributes.swift; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 9D1EF4741C9010960046BCD0 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 9D1EF46E1C9010960046BCD0 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 9D1EF4791C9010960046BCD0 /* EasyAutoLayout */, 46 | 9D1EF4781C9010960046BCD0 /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 9D1EF4781C9010960046BCD0 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 9D1EF4771C9010960046BCD0 /* EasyAutoLayout.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 9D1EF4791C9010960046BCD0 /* EasyAutoLayout */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 9D1EF48C1C9010B70046BCD0 /* Extension */, 62 | 9D1EF47A1C9010960046BCD0 /* AppDelegate.swift */, 63 | 9D1EF47C1C9010960046BCD0 /* ViewController.swift */, 64 | 9D1EF47E1C9010960046BCD0 /* Main.storyboard */, 65 | 9D1EF4811C9010960046BCD0 /* Assets.xcassets */, 66 | 9D1EF4831C9010960046BCD0 /* LaunchScreen.storyboard */, 67 | 9D1EF4861C9010960046BCD0 /* Info.plist */, 68 | ); 69 | path = EasyAutoLayout; 70 | sourceTree = ""; 71 | }; 72 | 9D1EF48C1C9010B70046BCD0 /* Extension */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 9D1EF48D1C9010D80046BCD0 /* UIView+AutoLayout.swift */, 76 | 9D1EF48F1C9011A70046BCD0 /* RT_LayoutAttributes.swift */, 77 | ); 78 | path = Extension; 79 | sourceTree = ""; 80 | }; 81 | /* End PBXGroup section */ 82 | 83 | /* Begin PBXNativeTarget section */ 84 | 9D1EF4761C9010960046BCD0 /* EasyAutoLayout */ = { 85 | isa = PBXNativeTarget; 86 | buildConfigurationList = 9D1EF4891C9010960046BCD0 /* Build configuration list for PBXNativeTarget "EasyAutoLayout" */; 87 | buildPhases = ( 88 | 9D1EF4731C9010960046BCD0 /* Sources */, 89 | 9D1EF4741C9010960046BCD0 /* Frameworks */, 90 | 9D1EF4751C9010960046BCD0 /* Resources */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = EasyAutoLayout; 97 | productName = EasyAutoLayout; 98 | productReference = 9D1EF4771C9010960046BCD0 /* EasyAutoLayout.app */; 99 | productType = "com.apple.product-type.application"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | 9D1EF46F1C9010960046BCD0 /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastSwiftUpdateCheck = 0720; 108 | LastUpgradeCheck = 0720; 109 | ORGANIZATIONNAME = yangtao; 110 | TargetAttributes = { 111 | 9D1EF4761C9010960046BCD0 = { 112 | CreatedOnToolsVersion = 7.2; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 9D1EF4721C9010960046BCD0 /* Build configuration list for PBXProject "EasyAutoLayout" */; 117 | compatibilityVersion = "Xcode 3.2"; 118 | developmentRegion = English; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 9D1EF46E1C9010960046BCD0; 125 | productRefGroup = 9D1EF4781C9010960046BCD0 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 9D1EF4761C9010960046BCD0 /* EasyAutoLayout */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 9D1EF4751C9010960046BCD0 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 9D1EF4851C9010960046BCD0 /* LaunchScreen.storyboard in Resources */, 140 | 9D1EF4821C9010960046BCD0 /* Assets.xcassets in Resources */, 141 | 9D1EF4801C9010960046BCD0 /* Main.storyboard in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 9D1EF4731C9010960046BCD0 /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 9D1EF47D1C9010960046BCD0 /* ViewController.swift in Sources */, 153 | 9D1EF48E1C9010D80046BCD0 /* UIView+AutoLayout.swift in Sources */, 154 | 9D1EF4901C9011A70046BCD0 /* RT_LayoutAttributes.swift in Sources */, 155 | 9D1EF47B1C9010960046BCD0 /* AppDelegate.swift in Sources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXSourcesBuildPhase section */ 160 | 161 | /* Begin PBXVariantGroup section */ 162 | 9D1EF47E1C9010960046BCD0 /* Main.storyboard */ = { 163 | isa = PBXVariantGroup; 164 | children = ( 165 | 9D1EF47F1C9010960046BCD0 /* Base */, 166 | ); 167 | name = Main.storyboard; 168 | sourceTree = ""; 169 | }; 170 | 9D1EF4831C9010960046BCD0 /* LaunchScreen.storyboard */ = { 171 | isa = PBXVariantGroup; 172 | children = ( 173 | 9D1EF4841C9010960046BCD0 /* Base */, 174 | ); 175 | name = LaunchScreen.storyboard; 176 | sourceTree = ""; 177 | }; 178 | /* End PBXVariantGroup section */ 179 | 180 | /* Begin XCBuildConfiguration section */ 181 | 9D1EF4871C9010960046BCD0 /* Debug */ = { 182 | isa = XCBuildConfiguration; 183 | buildSettings = { 184 | ALWAYS_SEARCH_USER_PATHS = NO; 185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 186 | CLANG_CXX_LIBRARY = "libc++"; 187 | CLANG_ENABLE_MODULES = YES; 188 | CLANG_ENABLE_OBJC_ARC = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_CONSTANT_CONVERSION = YES; 191 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 192 | CLANG_WARN_EMPTY_BODY = YES; 193 | CLANG_WARN_ENUM_CONVERSION = YES; 194 | CLANG_WARN_INT_CONVERSION = YES; 195 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 196 | CLANG_WARN_UNREACHABLE_CODE = YES; 197 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 198 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 199 | COPY_PHASE_STRIP = NO; 200 | DEBUG_INFORMATION_FORMAT = dwarf; 201 | ENABLE_STRICT_OBJC_MSGSEND = YES; 202 | ENABLE_TESTABILITY = YES; 203 | GCC_C_LANGUAGE_STANDARD = gnu99; 204 | GCC_DYNAMIC_NO_PIC = NO; 205 | GCC_NO_COMMON_BLOCKS = YES; 206 | GCC_OPTIMIZATION_LEVEL = 0; 207 | GCC_PREPROCESSOR_DEFINITIONS = ( 208 | "DEBUG=1", 209 | "$(inherited)", 210 | ); 211 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 212 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 213 | GCC_WARN_UNDECLARED_SELECTOR = YES; 214 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 215 | GCC_WARN_UNUSED_FUNCTION = YES; 216 | GCC_WARN_UNUSED_VARIABLE = YES; 217 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 218 | MTL_ENABLE_DEBUG_INFO = YES; 219 | ONLY_ACTIVE_ARCH = YES; 220 | SDKROOT = iphoneos; 221 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 222 | }; 223 | name = Debug; 224 | }; 225 | 9D1EF4881C9010960046BCD0 /* Release */ = { 226 | isa = XCBuildConfiguration; 227 | buildSettings = { 228 | ALWAYS_SEARCH_USER_PATHS = NO; 229 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 230 | CLANG_CXX_LIBRARY = "libc++"; 231 | CLANG_ENABLE_MODULES = YES; 232 | CLANG_ENABLE_OBJC_ARC = YES; 233 | CLANG_WARN_BOOL_CONVERSION = YES; 234 | CLANG_WARN_CONSTANT_CONVERSION = YES; 235 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 236 | CLANG_WARN_EMPTY_BODY = YES; 237 | CLANG_WARN_ENUM_CONVERSION = YES; 238 | CLANG_WARN_INT_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_UNREACHABLE_CODE = YES; 241 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 242 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 243 | COPY_PHASE_STRIP = NO; 244 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 245 | ENABLE_NS_ASSERTIONS = NO; 246 | ENABLE_STRICT_OBJC_MSGSEND = YES; 247 | GCC_C_LANGUAGE_STANDARD = gnu99; 248 | GCC_NO_COMMON_BLOCKS = YES; 249 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 250 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 251 | GCC_WARN_UNDECLARED_SELECTOR = YES; 252 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 253 | GCC_WARN_UNUSED_FUNCTION = YES; 254 | GCC_WARN_UNUSED_VARIABLE = YES; 255 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 256 | MTL_ENABLE_DEBUG_INFO = NO; 257 | SDKROOT = iphoneos; 258 | VALIDATE_PRODUCT = YES; 259 | }; 260 | name = Release; 261 | }; 262 | 9D1EF48A1C9010960046BCD0 /* Debug */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 266 | INFOPLIST_FILE = EasyAutoLayout/Info.plist; 267 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 268 | PRODUCT_BUNDLE_IDENTIFIER = rain.yang.EasyAutoLayout; 269 | PRODUCT_NAME = "$(TARGET_NAME)"; 270 | }; 271 | name = Debug; 272 | }; 273 | 9D1EF48B1C9010960046BCD0 /* Release */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 277 | INFOPLIST_FILE = EasyAutoLayout/Info.plist; 278 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 279 | PRODUCT_BUNDLE_IDENTIFIER = rain.yang.EasyAutoLayout; 280 | PRODUCT_NAME = "$(TARGET_NAME)"; 281 | }; 282 | name = Release; 283 | }; 284 | /* End XCBuildConfiguration section */ 285 | 286 | /* Begin XCConfigurationList section */ 287 | 9D1EF4721C9010960046BCD0 /* Build configuration list for PBXProject "EasyAutoLayout" */ = { 288 | isa = XCConfigurationList; 289 | buildConfigurations = ( 290 | 9D1EF4871C9010960046BCD0 /* Debug */, 291 | 9D1EF4881C9010960046BCD0 /* Release */, 292 | ); 293 | defaultConfigurationIsVisible = 0; 294 | defaultConfigurationName = Release; 295 | }; 296 | 9D1EF4891C9010960046BCD0 /* Build configuration list for PBXNativeTarget "EasyAutoLayout" */ = { 297 | isa = XCConfigurationList; 298 | buildConfigurations = ( 299 | 9D1EF48A1C9010960046BCD0 /* Debug */, 300 | 9D1EF48B1C9010960046BCD0 /* Release */, 301 | ); 302 | defaultConfigurationIsVisible = 0; 303 | }; 304 | /* End XCConfigurationList section */ 305 | }; 306 | rootObject = 9D1EF46F1C9010960046BCD0 /* Project object */; 307 | } 308 | -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeXiaoQiang/EasyAutoLayout-swift/9055fa264cbc260db0554365c82dfae9548198a0/EasyAutoLayout/EasyAutoLayout/.DS_Store -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // EasyAutoLayout 4 | // 5 | // Created by yangtao on 3/9/16. 6 | // Copyright © 2016 yangtao. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/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 | } -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/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 | -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/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 | -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/Extension/RT_LayoutAttributes.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+AutoLayout.swift 3 | // EasyAutoLayout 4 | // 5 | // Created by yangtao on 3/8/16. 6 | // Copyright © 2016 yangtao. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class RT_LayoutAttributes { 12 | 13 | var horizontal: NSLayoutAttribute 14 | var referHorizontal: NSLayoutAttribute 15 | var vertical: NSLayoutAttribute 16 | var referVertical: NSLayoutAttribute 17 | 18 | init() { 19 | horizontal = NSLayoutAttribute.Left 20 | referHorizontal = NSLayoutAttribute.Left 21 | vertical = NSLayoutAttribute.Top 22 | referVertical = NSLayoutAttribute.Top 23 | } 24 | 25 | init(horizontal: NSLayoutAttribute, referHorizontal: NSLayoutAttribute, vertical: NSLayoutAttribute, referVertical: NSLayoutAttribute) { 26 | 27 | self.horizontal = horizontal 28 | self.referHorizontal = referHorizontal 29 | self.vertical = vertical 30 | self.referVertical = referVertical 31 | } 32 | 33 | func horizontals(from: NSLayoutAttribute, to: NSLayoutAttribute) -> Self { 34 | horizontal = from 35 | referHorizontal = to 36 | 37 | return self 38 | } 39 | 40 | func verticals(from: NSLayoutAttribute, to: NSLayoutAttribute) -> Self { 41 | vertical = from 42 | referVertical = to 43 | 44 | return self 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/Extension/UIView+AutoLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+AutoLayout.swift 3 | // EasyAutoLayout 4 | // 5 | // Created by yangtao on 3/8/16. 6 | // Copyright © 2016 yangtao. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | /** 11 | 对齐类型枚举,设置控件相对于父视图的位置 12 | - TopLeft: 左上 13 | - TopRight: 右上 14 | - TopCenter: 中上 15 | - BottomLeft: 左下 16 | - BottomRight: 右下 17 | - BottomCenter: 中下 18 | - CenterLeft: 左中 19 | - CenterRight: 右中 20 | - Center: 中中 21 | */ 22 | public enum RT_AlignType { 23 | case TopLeft 24 | case TopRight 25 | case TopCenter 26 | case BottomLeft 27 | case BottomRight 28 | case BottomCenter 29 | case CenterLeft 30 | case CenterRight 31 | case Center 32 | 33 | private func layoutAttributes(isInner: Bool, isVertical: Bool) -> RT_LayoutAttributes { 34 | let attributes = RT_LayoutAttributes() 35 | 36 | switch self { 37 | case .TopLeft: 38 | attributes.horizontals(.Left, to: .Left).verticals(.Top, to: .Top) 39 | 40 | if isInner { 41 | return attributes 42 | } else if isVertical { 43 | return attributes.verticals(.Bottom, to: .Top) 44 | } else { 45 | return attributes.horizontals(.Right, to: .Left) 46 | } 47 | case .TopRight: 48 | attributes.horizontals(.Right, to: .Right).verticals(.Top, to: .Top) 49 | 50 | if isInner { 51 | return attributes 52 | } else if isVertical { 53 | return attributes.verticals(.Bottom, to: .Top) 54 | } else { 55 | return attributes.horizontals(.Left, to: .Right) 56 | } 57 | case .BottomLeft: 58 | attributes.horizontals(.Left, to: .Left).verticals(.Bottom, to: .Bottom) 59 | 60 | if isInner { 61 | return attributes 62 | } else if isVertical { 63 | return attributes.verticals(.Top, to: .Bottom) 64 | } else { 65 | return attributes.horizontals(.Right, to: .Left) 66 | } 67 | case .BottomRight: 68 | attributes.horizontals(.Right, to: .Right).verticals(.Bottom, to: .Bottom) 69 | 70 | if isInner { 71 | return attributes 72 | } else if isVertical { 73 | return attributes.verticals(.Top, to: .Bottom) 74 | } else { 75 | return attributes.horizontals(.Left, to: .Right) 76 | } 77 | // 仅内部 & 垂直参照需要 78 | case .TopCenter: 79 | attributes.horizontals(.CenterX, to: .CenterX).verticals(.Top, to: .Top) 80 | return isInner ? attributes : attributes.verticals(.Bottom, to: .Top) 81 | // 仅内部 & 垂直参照需要 82 | case .BottomCenter: 83 | attributes.horizontals(.CenterX, to: .CenterX).verticals(.Bottom, to: .Bottom) 84 | return isInner ? attributes : attributes.verticals(.Top, to: .Bottom) 85 | // 仅内部 & 水平参照需要 86 | case .CenterLeft: 87 | attributes.horizontals(.Left, to: .Left).verticals(.CenterY, to: .CenterY) 88 | return isInner ? attributes : attributes.horizontals(.Right, to: .Left) 89 | // 仅内部 & 水平参照需要 90 | case .CenterRight: 91 | attributes.horizontals(.Right, to: .Right).verticals(.CenterY, to: .CenterY) 92 | return isInner ? attributes : attributes.horizontals(.Left, to: .Right) 93 | // 仅内部参照需要 94 | case .Center: 95 | return RT_LayoutAttributes(horizontal: .CenterX, referHorizontal: .CenterX, vertical: .CenterY, referVertical: .CenterY) 96 | } 97 | } 98 | } 99 | 100 | extension UIView { 101 | 102 | /** 103 | 宽高约束 104 | */ 105 | public func RT_AlignInnerWidth(width:CGFloat) -> NSLayoutConstraint{ 106 | 107 | let cons = NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: width) 108 | 109 | addConstraint(cons) 110 | return cons 111 | } 112 | 113 | 114 | public func RT_AlignInnerHeight(height:CGFloat) -> NSLayoutConstraint{ 115 | 116 | let cons = NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: height) 117 | addConstraint(cons) 118 | return cons 119 | } 120 | 121 | 122 | /** 123 | 填充子视图 124 | 125 | :param: referView 参考视图 126 | :param: insets 间距 127 | 128 | :returns: 约束数组 129 | */ 130 | public func RT_Fill(referView: UIView, insets: UIEdgeInsets = UIEdgeInsetsZero) -> [NSLayoutConstraint] { 131 | translatesAutoresizingMaskIntoConstraints = false 132 | 133 | var cons = [NSLayoutConstraint]() 134 | 135 | cons += NSLayoutConstraint.constraintsWithVisualFormat("H:|-\(insets.left)-[subView]-\(insets.right)-|", options: NSLayoutFormatOptions.AlignAllBaseline, metrics: nil, views: ["subView" : self]) 136 | cons += NSLayoutConstraint.constraintsWithVisualFormat("V:|-\(insets.top)-[subView]-\(insets.bottom)-|", options: NSLayoutFormatOptions.AlignAllBaseline, metrics: nil, views: ["subView" : self]) 137 | 138 | superview?.addConstraints(cons) 139 | 140 | return cons 141 | } 142 | 143 | /** 144 | 参照参考视图内部对齐 145 | 146 | :param: type 对齐方式 147 | :param: referView 参考视图 148 | :param: size 视图大小,如果是 nil 则不设置大小 149 | :param: offset 偏移量,默认是 CGPoint(x: 0, y: 0) 150 | 151 | :returns: 约束数组 152 | */ 153 | public func RT_AlignInner(type type: RT_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint] { 154 | 155 | return RT_AlignLayout(referView, attributes: type.layoutAttributes(true, isVertical: true), size: size, offset: offset) 156 | } 157 | 158 | /** 159 | 参照参考视图垂直对齐 160 | 161 | :param: type 对齐方式 162 | :param: referView 参考视图 163 | :param: size 视图大小,如果是 nil 则不设置大小 164 | :param: offset 偏移量,默认是 CGPoint(x: 0, y: 0) 165 | 166 | :returns: 约束数组 167 | */ 168 | public func RT_AlignVertical(type type: RT_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint] { 169 | 170 | return RT_AlignLayout(referView, attributes: type.layoutAttributes(false, isVertical: true), size: size, offset: offset) 171 | } 172 | 173 | /** 174 | 参照参考视图水平对齐 175 | 176 | :param: type 对齐方式 177 | :param: referView 参考视图 178 | :param: size 视图大小,如果是 nil 则不设置大小 179 | :param: offset 偏移量,默认是 CGPoint(x: 0, y: 0) 180 | 181 | :returns: 约束数组 182 | */ 183 | public func RT_AlignHorizontal(type type: RT_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint] { 184 | 185 | return RT_AlignLayout(referView, attributes: type.layoutAttributes(false, isVertical: false), size: size, offset: offset) 186 | } 187 | 188 | /** 189 | 在当前视图内部水平平铺控件 190 | 191 | :param: views 子视图数组 192 | :param: insets 间距 193 | 194 | :returns: 约束数组 195 | */ 196 | public func RT_HorizontalTile(views: [UIView], insets: UIEdgeInsets) -> [NSLayoutConstraint] { 197 | 198 | assert(!views.isEmpty, "views should not be empty") 199 | 200 | var cons = [NSLayoutConstraint]() 201 | 202 | let firstView = views[0] 203 | firstView.RT_AlignInner(type: RT_AlignType.TopLeft, referView: self, size: nil, offset: CGPoint(x: insets.left, y: insets.top)) 204 | cons.append(NSLayoutConstraint(item: firstView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: -insets.bottom)) 205 | 206 | // 添加后续视图的约束 207 | var preView = firstView 208 | for i in 1.. [NSLayoutConstraint] { 231 | 232 | assert(!views.isEmpty, "views should not be empty") 233 | 234 | var cons = [NSLayoutConstraint]() 235 | 236 | let firstView = views[0] 237 | firstView.RT_AlignInner(type: RT_AlignType.TopLeft, referView: self, size: nil, offset: CGPoint(x: insets.left, y: insets.top)) 238 | cons.append(NSLayoutConstraint(item: firstView, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Right, multiplier: 1.0, constant: -insets.right)) 239 | 240 | // 添加后续视图的约束 241 | var preView = firstView 242 | for i in 1.. NSLayoutConstraint? { 266 | for constraint in constraintsList { 267 | if constraint.firstItem as! NSObject == self && constraint.firstAttribute == attribute { 268 | return constraint 269 | } 270 | } 271 | 272 | return nil 273 | } 274 | 275 | // MARK: - 私有函数 276 | /** 277 | 参照参考视图对齐布局 278 | 279 | :param: referView 参考视图 280 | :param: attributes 参照属性 281 | :param: size 视图大小,如果是 nil 则不设置大小 282 | :param: offset 偏移量,默认是 CGPoint(x: 0, y: 0) 283 | 284 | :returns: 约束数组 285 | */ 286 | private func RT_AlignLayout(referView: UIView, attributes: RT_LayoutAttributes, size: CGSize?, offset: CGPoint) -> [NSLayoutConstraint] { 287 | 288 | translatesAutoresizingMaskIntoConstraints = false 289 | 290 | var cons = [NSLayoutConstraint]() 291 | 292 | cons += RT_positionConstraints(referView, attributes: attributes, offset: offset) 293 | 294 | if size != nil { 295 | cons += RT_sizeConstraints(size!) 296 | } 297 | 298 | superview?.addConstraints(cons) 299 | 300 | return cons 301 | } 302 | 303 | 304 | /** 305 | 尺寸约束数组 306 | 307 | :param: size 视图大小 308 | 309 | :returns: 约束数组 310 | */ 311 | private func RT_sizeConstraints(size: CGSize) -> [NSLayoutConstraint] { 312 | 313 | var cons = [NSLayoutConstraint]() 314 | 315 | cons.append(NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: size.width)) 316 | cons.append(NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: size.height)) 317 | 318 | return cons 319 | } 320 | 321 | 322 | /** 323 | 尺寸约束数组 324 | 325 | :param: referView 参考视图,与参考视图大小一致 326 | 327 | :returns: 约束数组 328 | */ 329 | private func RT_sizeConstraints(referView: UIView) -> [NSLayoutConstraint] { 330 | 331 | var cons = [NSLayoutConstraint]() 332 | 333 | cons.append(NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: referView, attribute: NSLayoutAttribute.Width, multiplier: 1.0, constant: 0)) 334 | cons.append(NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: referView, attribute: NSLayoutAttribute.Height, multiplier: 1.0, constant: 0)) 335 | 336 | return cons 337 | } 338 | 339 | /** 340 | 位置约束数组 341 | 342 | :param: referView 参考视图 343 | :param: attributes 参照属性 344 | :param: offset 偏移量 345 | 346 | :returns: 约束数组 347 | */ 348 | private func RT_positionConstraints(referView: UIView, attributes: RT_LayoutAttributes, offset: CGPoint) -> [NSLayoutConstraint] { 349 | 350 | var cons = [NSLayoutConstraint]() 351 | 352 | cons.append(NSLayoutConstraint(item: self, attribute: attributes.horizontal, relatedBy: NSLayoutRelation.Equal, toItem: referView, attribute: attributes.referHorizontal, multiplier: 1.0, constant: offset.x)) 353 | cons.append(NSLayoutConstraint(item: self, attribute: attributes.vertical, relatedBy: NSLayoutRelation.Equal, toItem: referView, attribute: attributes.referVertical, multiplier: 1.0, constant: offset.y)) 354 | 355 | return cons 356 | } 357 | } 358 | -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/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 | -------------------------------------------------------------------------------- /EasyAutoLayout/EasyAutoLayout/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // EasyAutoLayout 4 | // 5 | // Created by yangtao on 3/9/16. 6 | // Copyright © 2016 yangtao. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | 17 | let redView = UIView() 18 | redView.backgroundColor = UIColor.redColor() 19 | view.addSubview(redView) 20 | 21 | let greenView = UIView() 22 | greenView.backgroundColor = UIColor.greenColor() 23 | view.addSubview(greenView) 24 | 25 | let blueView = UIView() 26 | blueView.backgroundColor = UIColor.blueColor() 27 | view.addSubview(blueView) 28 | 29 | let blackView = UIView() 30 | blackView.backgroundColor = UIColor.blackColor() 31 | view.addSubview(blackView) 32 | 33 | 34 | 35 | // redView.RT_AlignVertical(type: .Center, referView: view, size: nil) 36 | // redView.RT_AlignInnerWidth(224) 37 | // redView.RT_AlignInnerHeight(20) 38 | 39 | //redView.RT_AlignVertical(type: .Center, referView: view, size: CGSizeMake(100, 100), offset: CGPointMake(0, 100)) 40 | 41 | //redView.RT_Fill(view, insets: UIEdgeInsetsMake(74, 10, 74, 10)) 42 | 43 | //greenView.RT_AlignHorizontal(type: .TopLeft, referView: redView, size: CGSizeMake(100, 100)) 44 | 45 | // greenView.RT_AlignHorizontal(type:.Center , referView: redView, size: CGSizeMake(100, 100), offset: CGPointMake(0, 120)) 46 | 47 | //let cons = greenView.RT_AlignInner(type: .TopLeft, referView: redView, size: CGSizeMake(100, 100), offset: CGPointMake(10, 30)) 48 | //greenConstraint = greenView.RT_Constraint(cons, attribute: .Top) 49 | 50 | //greenView.RT_AlignVertical(type: .TopLeft, referView: redView, size: CGSizeMake(100, 100), offset: CGPointMake(10, 30)) 51 | 52 | //greenView.RT_AlignHorizontal(type: .TopLeft, referView: redView, size: CGSizeMake(100, 100), offset: CGPointMake(10, 30)) 53 | 54 | let arry = [redView, greenView, blueView]; 55 | view.RT_VerticalTile(arry, insets: UIEdgeInsetsMake(74, 10, 10, 10)) 56 | 57 | print("redView === \(redView.frame)") 58 | 59 | } 60 | 61 | override func didReceiveMemoryWarning() { 62 | super.didReceiveMemoryWarning() 63 | // Dispose of any resources that can be recreated. 64 | } 65 | 66 | 67 | } 68 | 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 codeXiaoQiang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### EasyAutoLayout-swift 2 | ================= 3 | 与UIView+AutoLayout,masonry这两款主流的自动布局框架相比,虽然功能不够强大,但是解决基本的布局是没有问题的.框架实现是基于`UIView`的分类,开发者只要把`Extension`拖入项目中就可以使用,大大减少了使用第三方的依赖,一行代码搞定布局,没有冗余的垃圾代码.[oc版请戳这里!!!!!!!!!!!](https://github.com/codeXiaoQiang/EasyAutoLayout) 4 | 5 | ## EasyAutoLayout 6 | 7 | **宽高约束** 8 | ``` 9 | public func RT_AlignInnerWidth(width:CGFloat) -> NSLayoutConstraint 10 | public func RT_AlignInnerHeight(height:CGFloat) -> NSLayoutConstraint 11 | ``` 12 | **填充子视图** 13 | ``` 14 | public func RT_Fill(referView: UIView, insets: UIEdgeInsets = UIEdgeInsetsZero) 15 | ``` 16 | **参照参考视图内部对齐** 17 | ``` 18 | public func RT_AlignInner(type type: RT_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint] 19 | ``` 20 | **参照参考视图垂直对齐** 21 | ``` 22 | public func RT_AlignVertical(type type: RT_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint] 23 | ``` 24 | **参照参考视图水平对齐** 25 | ``` 26 | public func RT_AlignHorizontal(type type: RT_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint] 27 | ``` 28 | ** 在当前视图内部水平平铺控件** 29 | ``` 30 | public func RT_HorizontalTile(views: [UIView], insets: UIEdgeInsets) -> [NSLayoutConstraint] 31 | ``` 32 | ** 在当前视图内部垂直平铺控件** 33 | ``` 34 | public func RT_VerticalTile(views: [UIView], insets: UIEdgeInsets) -> [NSLayoutConstraint] 35 | ``` 36 | ** 从约束数组中查找指定 attribute 的约束** 37 | ``` 38 | public func RT_Constraint(constraintsList: [NSLayoutConstraint], attribute: NSLayoutAttribute) -> NSLayoutConstraint? 39 | ``` 40 | ## Example 41 | **填充子视图** 42 | ``` 43 | - (NSArray*)RT_Fill:(UIView*)referView; 44 | ``` 45 | ================= 46 | ![image](https://github.com/codeXiaoQiang/EasyAutoLayout/blob/master/1.png) 47 | 48 | ** 在当前视图内部水平平铺控件** 49 | ``` 50 | - (NSArray*)RT_HorizontalTile:(NSArray*)views insets:(UIEdgeInsets)insets; 51 | ``` 52 | ================= 53 | ![image](https://github.com/codeXiaoQiang/EasyAutoLayout/blob/master/2.png) 54 | 55 | 56 | --------------------------------------------------------------------------------