From 1d3b46bad897afa025019059f8e0c75b4d90ae1d Mon Sep 17 00:00:00 2001 From: Matt Neuburg Date: Mon, 18 Jul 2016 21:17:10 -0700 Subject: [PATCH] more book 2 chapter 1 tweaks --- .../project.pbxproj | 304 ++++++++++++++++++ .../AppDelegate.swift | 19 ++ .../AppIcon.appiconset/Contents.json | 38 +++ .../Base.lproj/LaunchScreen.storyboard | 27 ++ .../Base.lproj/Main.storyboard | 27 ++ .../ImplicitConstraintsInNib/Info.plist | 39 +++ .../ViewController.swift | 102 ++++++ .../ch14p382autoresizing/AppDelegate.swift | 3 +- 8 files changed, 558 insertions(+), 1 deletion(-) create mode 100644 bk2ch01p025autoresizingConstraints/AutoresizingConstraints.xcodeproj/project.pbxproj create mode 100644 bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/AppDelegate.swift create mode 100644 bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Base.lproj/LaunchScreen.storyboard create mode 100644 bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Base.lproj/Main.storyboard create mode 100644 bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Info.plist create mode 100644 bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/ViewController.swift diff --git a/bk2ch01p025autoresizingConstraints/AutoresizingConstraints.xcodeproj/project.pbxproj b/bk2ch01p025autoresizingConstraints/AutoresizingConstraints.xcodeproj/project.pbxproj new file mode 100644 index 000000000..e5d1abcae --- /dev/null +++ b/bk2ch01p025autoresizingConstraints/AutoresizingConstraints.xcodeproj/project.pbxproj @@ -0,0 +1,304 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 8102E3F61D3C4D5400912F69 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8102E3F51D3C4D5400912F69 /* AppDelegate.swift */; }; + 8102E3F81D3C4D5400912F69 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8102E3F71D3C4D5400912F69 /* ViewController.swift */; }; + 8102E3FB1D3C4D5400912F69 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8102E3F91D3C4D5400912F69 /* Main.storyboard */; }; + 8102E3FD1D3C4D5400912F69 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8102E3FC1D3C4D5400912F69 /* Assets.xcassets */; }; + 8102E4001D3C4D5400912F69 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8102E3FE1D3C4D5400912F69 /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 8102E3F21D3C4D5400912F69 /* AutoresizingConstraints.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AutoresizingConstraints.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 8102E3F51D3C4D5400912F69 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 8102E3F71D3C4D5400912F69 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 8102E3FA1D3C4D5400912F69 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 8102E3FC1D3C4D5400912F69 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 8102E3FF1D3C4D5400912F69 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 8102E4011D3C4D5400912F69 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8102E3EF1D3C4D5400912F69 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 8102E3E91D3C4D5400912F69 = { + isa = PBXGroup; + children = ( + 8102E3F41D3C4D5400912F69 /* AutoresizingConstraints */, + 8102E3F31D3C4D5400912F69 /* Products */, + ); + sourceTree = ""; + }; + 8102E3F31D3C4D5400912F69 /* Products */ = { + isa = PBXGroup; + children = ( + 8102E3F21D3C4D5400912F69 /* AutoresizingConstraints.app */, + ); + name = Products; + sourceTree = ""; + }; + 8102E3F41D3C4D5400912F69 /* AutoresizingConstraints */ = { + isa = PBXGroup; + children = ( + 8102E3F51D3C4D5400912F69 /* AppDelegate.swift */, + 8102E3F71D3C4D5400912F69 /* ViewController.swift */, + 8102E3F91D3C4D5400912F69 /* Main.storyboard */, + 8102E3FC1D3C4D5400912F69 /* Assets.xcassets */, + 8102E3FE1D3C4D5400912F69 /* LaunchScreen.storyboard */, + 8102E4011D3C4D5400912F69 /* Info.plist */, + ); + name = AutoresizingConstraints; + path = ImplicitConstraintsInNib; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8102E3F11D3C4D5400912F69 /* AutoresizingConstraints */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8102E4041D3C4D5400912F69 /* Build configuration list for PBXNativeTarget "AutoresizingConstraints" */; + buildPhases = ( + 8102E3EE1D3C4D5400912F69 /* Sources */, + 8102E3EF1D3C4D5400912F69 /* Frameworks */, + 8102E3F01D3C4D5400912F69 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AutoresizingConstraints; + productName = ImplicitConstraintsInNib; + productReference = 8102E3F21D3C4D5400912F69 /* AutoresizingConstraints.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8102E3EA1D3C4D5400912F69 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0800; + LastUpgradeCheck = 0800; + ORGANIZATIONNAME = "Mattt Neuburg"; + TargetAttributes = { + 8102E3F11D3C4D5400912F69 = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = W3LHX5RGV2; + DevelopmentTeamName = "Matt Neuburg"; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 8102E3ED1D3C4D5400912F69 /* Build configuration list for PBXProject "AutoresizingConstraints" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 8102E3E91D3C4D5400912F69; + productRefGroup = 8102E3F31D3C4D5400912F69 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8102E3F11D3C4D5400912F69 /* AutoresizingConstraints */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8102E3F01D3C4D5400912F69 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8102E4001D3C4D5400912F69 /* LaunchScreen.storyboard in Resources */, + 8102E3FD1D3C4D5400912F69 /* Assets.xcassets in Resources */, + 8102E3FB1D3C4D5400912F69 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8102E3EE1D3C4D5400912F69 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8102E3F81D3C4D5400912F69 /* ViewController.swift in Sources */, + 8102E3F61D3C4D5400912F69 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 8102E3F91D3C4D5400912F69 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 8102E3FA1D3C4D5400912F69 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 8102E3FE1D3C4D5400912F69 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 8102E3FF1D3C4D5400912F69 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 8102E4021D3C4D5400912F69 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 8102E4031D3C4D5400912F69 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 8102E4051D3C4D5400912F69 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = ImplicitConstraintsInNib/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.neuburg.matt.ImplicitConstraintsInNib; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 8102E4061D3C4D5400912F69 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = ImplicitConstraintsInNib/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.neuburg.matt.ImplicitConstraintsInNib; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 8102E3ED1D3C4D5400912F69 /* Build configuration list for PBXProject "AutoresizingConstraints" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8102E4021D3C4D5400912F69 /* Debug */, + 8102E4031D3C4D5400912F69 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8102E4041D3C4D5400912F69 /* Build configuration list for PBXNativeTarget "AutoresizingConstraints" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8102E4051D3C4D5400912F69 /* Debug */, + 8102E4061D3C4D5400912F69 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 8102E3EA1D3C4D5400912F69 /* Project object */; +} diff --git a/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/AppDelegate.swift b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/AppDelegate.swift new file mode 100644 index 000000000..a7e27081b --- /dev/null +++ b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/AppDelegate.swift @@ -0,0 +1,19 @@ + + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + // Override point for customization after application launch. + return true + } + + + +} + diff --git a/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Assets.xcassets/AppIcon.appiconset/Contents.json b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..118c98f74 --- /dev/null +++ b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Base.lproj/LaunchScreen.storyboard b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..fdf3f97d1 --- /dev/null +++ b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Base.lproj/Main.storyboard b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Base.lproj/Main.storyboard new file mode 100644 index 000000000..df984e7ef --- /dev/null +++ b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Base.lproj/Main.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Info.plist b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Info.plist new file mode 100644 index 000000000..70d2e952a --- /dev/null +++ b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/Info.plist @@ -0,0 +1,39 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortraitUpsideDown + + + diff --git a/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/ViewController.swift b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/ViewController.swift new file mode 100644 index 000000000..8b238756d --- /dev/null +++ b/bk2ch01p025autoresizingConstraints/ImplicitConstraintsInNib/ViewController.swift @@ -0,0 +1,102 @@ + + +import UIKit + +func delay(_ delay:Double, closure:()->()) { + let when = DispatchTime.now() + delay + DispatchQueue.main.after(when: when, execute: closure) +} + + +extension CGRect { + init(_ x:CGFloat, _ y:CGFloat, _ w:CGFloat, _ h:CGFloat) { + self.init(x:x, y:y, width:w, height:h) + } +} +extension CGSize { + init(_ width:CGFloat, _ height:CGFloat) { + self.init(width:width, height:height) + } +} +extension CGPoint { + init(_ x:CGFloat, _ y:CGFloat) { + self.init(x:x, y:y) + } +} +extension CGVector { + init (_ dx:CGFloat, _ dy:CGFloat) { + self.init(dx:dx, dy:dy) + } +} + +extension NSLayoutConstraint { + class func reportAmbiguity (_ v:UIView?) { + var v = v + if v == nil { + v = UIApplication.shared().keyWindow + } + for vv in v!.subviews { + print("\(vv) \(vv.hasAmbiguousLayout())") + if vv.subviews.count > 0 { + self.reportAmbiguity(vv) + } + } + } + class func listConstraints (_ v:UIView?) { + var v = v + if v == nil { + v = UIApplication.shared().keyWindow + } + for vv in v!.subviews { + let arr1 = vv.constraintsAffectingLayout(for:.horizontal) + let arr2 = vv.constraintsAffectingLayout(for:.vertical) + NSLog("\n\n%@\nH: %@\nV:%@", vv, arr1, arr2); + if vv.subviews.count > 0 { + self.listConstraints(vv) + } + } + } +} + + +class ViewController: UIViewController { + + weak var lab1: UILabel! + weak var lab2: UILabel! + + override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { + return .allButUpsideDown + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + let lab1 = UILabel(frame:CGRect(313,20,42,22)) + lab1.autoresizingMask = [.flexibleLeftMargin, .flexibleBottomMargin] + lab1.text = "Hello" + self.view.addSubview(lab1) + self.lab1 = lab1 + + let lab2 = UILabel() + lab2.translatesAutoresizingMaskIntoConstraints = false + lab2.text = "Howdy" + self.view.addSubview(lab2) + self.lab2 = lab2 + + + // the way to test this is to add another label and pin to the first one + + NSLayoutConstraint.activate([ + lab2.topAnchor.constraint(equalTo: lab1.bottomAnchor, constant: 20), + lab2.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -20) + ]) + + + delay(2) { + NSLayoutConstraint.listConstraints(nil) + + } + } + +} + diff --git a/bk2ch01p031constraints/ch14p382autoresizing/AppDelegate.swift b/bk2ch01p031constraints/ch14p382autoresizing/AppDelegate.swift index bd1b897c2..1ff3a4d49 100644 --- a/bk2ch01p031constraints/ch14p382autoresizing/AppDelegate.swift +++ b/bk2ch01p031constraints/ch14p382autoresizing/AppDelegate.swift @@ -76,7 +76,7 @@ extension CGRect { v2.translatesAutoresizingMaskIntoConstraints = false v3.translatesAutoresizingMaskIntoConstraints = false - var which : Int {return 2} + var which : Int {return 3} switch which { case 1: // the old way, and this is the last time I'm going to show this @@ -174,6 +174,7 @@ extension CGRect { "V:|[v2(10)]", metrics: nil, views: d), NSLayoutConstraint.constraints(withVisualFormat: "H:[v3(20)]|", metrics: nil, views: d), + // comment me out to form an ambiguity NSLayoutConstraint.constraints(withVisualFormat: "V:[v3(20)]|", metrics: nil, views: d), // uncomment me to form a conflict