From b206d5ffd594c9489da67569628e2245c4f77ca1 Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 11:58:06 +0200 Subject: [PATCH 1/7] adding example project --- Example-iOS/AppDelegate.swift | 46 ++++++ .../AppIcon.appiconset/Contents.json | 38 +++++ .../Base.lproj/LaunchScreen.storyboard | 27 ++++ Example-iOS/Info.plist | 38 +++++ Example-iOS/ListViewController.swift | 24 +++ SnapKit.xcodeproj/project.pbxproj | 152 ++++++++++++++++++ 6 files changed, 325 insertions(+) create mode 100644 Example-iOS/AppDelegate.swift create mode 100644 Example-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Example-iOS/Base.lproj/LaunchScreen.storyboard create mode 100644 Example-iOS/Info.plist create mode 100644 Example-iOS/ListViewController.swift diff --git a/Example-iOS/AppDelegate.swift b/Example-iOS/AppDelegate.swift new file mode 100644 index 0000000..02e1dfa --- /dev/null +++ b/Example-iOS/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// Example-iOS +// +// Created by Spiros Gerokostas on 01/03/16. +// Copyright © 2016 SnapKit Team. All rights reserved. +// + +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 + } + + func applicationWillResignActive(application: UIApplication) { + // 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. + // 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. + } + + func applicationDidEnterBackground(application: UIApplication) { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(application: UIApplication) { + // 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. + } + + func applicationDidBecomeActive(application: UIApplication) { + // 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. + } + + func applicationWillTerminate(application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Example-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/Example-iOS/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/Example-iOS/Base.lproj/LaunchScreen.storyboard b/Example-iOS/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..2e721e1 --- /dev/null +++ b/Example-iOS/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example-iOS/Info.plist b/Example-iOS/Info.plist new file mode 100644 index 0000000..d39a4da --- /dev/null +++ b/Example-iOS/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Example-iOS/ListViewController.swift b/Example-iOS/ListViewController.swift new file mode 100644 index 0000000..3160956 --- /dev/null +++ b/Example-iOS/ListViewController.swift @@ -0,0 +1,24 @@ +// +// ViewController.swift +// Example-iOS +// +// Created by Spiros Gerokostas on 01/03/16. +// Copyright © 2016 SnapKit Team. All rights reserved. +// + +import UIKit +import SnapKit + +class ListViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + self.title = "SnapKit iOS Demos" + } + + + + +} + diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 7bdc1f9..d168c8d 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -23,6 +23,12 @@ 537DCEA91C35CE3E00B5B899 /* ConstraintAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB35F1AC0C95C006BBC11 /* ConstraintAttributes.swift */; }; 537DCEB41C35D90A00B5B899 /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 537DCE921C35CC8800B5B899 /* SnapKit.framework */; }; 537DCEBA1C35DA9700B5B899 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; }; + 56A0DC0E1C859E30005973AB /* ListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC0D1C859E30005973AB /* ListViewController.swift */; }; + 56A0DC131C859E30005973AB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 56A0DC121C859E30005973AB /* Assets.xcassets */; }; + 56A0DC161C859E30005973AB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 56A0DC141C859E30005973AB /* LaunchScreen.storyboard */; }; + 56A0DC1C1C859E9A005973AB /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; + 56A0DC1D1C859E9A005973AB /* SnapKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 56A0DC221C859F15005973AB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC211C859F15005973AB /* AppDelegate.swift */; }; EE4910981B19A26000A54F1F /* ViewController+SnapKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */; }; EE4910991B19A40200A54F1F /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; EE94F6091AC0F10A008767FF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE94F6081AC0F10A008767FF /* UIKit.framework */; }; @@ -57,6 +63,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 56A0DC1E1C859E9A005973AB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = DDC9FD8D1981B4DD009612C7 /* Project object */; + proxyType = 1; + remoteGlobalIDString = EEBCC9D719CC627D0083B827; + remoteInfo = "SnapKit iOS"; + }; EECDB3861AC0C9D4006BBC11 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = DDC9FD8D1981B4DD009612C7 /* Project object */; @@ -66,10 +79,30 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 56A0DC201C859E9A005973AB /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 56A0DC1D1C859E9A005973AB /* SnapKit.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 537DCE921C35CC8800B5B899 /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 537DCE9A1C35CD4100B5B899 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 537DCEAF1C35D90A00B5B899 /* SnapKit tvOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SnapKit tvOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 56A0DC091C859E30005973AB /* Example-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 56A0DC0D1C859E30005973AB /* ListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListViewController.swift; sourceTree = ""; }; + 56A0DC121C859E30005973AB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 56A0DC151C859E30005973AB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 56A0DC171C859E30005973AB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 56A0DC211C859F15005973AB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ViewController+SnapKit.swift"; sourceTree = ""; }; EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -111,6 +144,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 56A0DC061C859E30005973AB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 56A0DC1C1C859E9A005973AB /* SnapKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; EE94F60D1AC0F132008767FF /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -146,10 +187,23 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 56A0DC0A1C859E30005973AB /* Example-iOS */ = { + isa = PBXGroup; + children = ( + 56A0DC211C859F15005973AB /* AppDelegate.swift */, + 56A0DC0D1C859E30005973AB /* ListViewController.swift */, + 56A0DC121C859E30005973AB /* Assets.xcassets */, + 56A0DC141C859E30005973AB /* LaunchScreen.storyboard */, + 56A0DC171C859E30005973AB /* Info.plist */, + ); + path = "Example-iOS"; + sourceTree = ""; + }; DDC9FD8C1981B4DD009612C7 = { isa = PBXGroup; children = ( EECDB35D1AC0C95C006BBC11 /* Source */, + 56A0DC0A1C859E30005973AB /* Example-iOS */, EE94F60C1AC0F113008767FF /* Frameworks */, DDC9FD961981B4DD009612C7 /* Products */, ); @@ -164,6 +218,7 @@ EECDB3841AC0C9D4006BBC11 /* SnapKit OSX Tests.xctest */, 537DCE921C35CC8800B5B899 /* SnapKit.framework */, 537DCEAF1C35D90A00B5B899 /* SnapKit tvOS Tests.xctest */, + 56A0DC091C859E30005973AB /* Example-iOS.app */, ); name = Products; sourceTree = ""; @@ -283,6 +338,25 @@ productReference = 537DCEAF1C35D90A00B5B899 /* SnapKit tvOS Tests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 56A0DC081C859E30005973AB /* Example-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 56A0DC1A1C859E30005973AB /* Build configuration list for PBXNativeTarget "Example-iOS" */; + buildPhases = ( + 56A0DC051C859E30005973AB /* Sources */, + 56A0DC061C859E30005973AB /* Frameworks */, + 56A0DC071C859E30005973AB /* Resources */, + 56A0DC201C859E9A005973AB /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 56A0DC1F1C859E9A005973AB /* PBXTargetDependency */, + ); + name = "Example-iOS"; + productName = "Example-iOS"; + productReference = 56A0DC091C859E30005973AB /* Example-iOS.app */; + productType = "com.apple.product-type.application"; + }; EEBCC9D719CC627D0083B827 /* SnapKit iOS */ = { isa = PBXNativeTarget; buildConfigurationList = EEBCC9E819CC627E0083B827 /* Build configuration list for PBXNativeTarget "SnapKit iOS" */; @@ -370,6 +444,9 @@ 537DCEAE1C35D90A00B5B899 = { CreatedOnToolsVersion = 7.2; }; + 56A0DC081C859E30005973AB = { + CreatedOnToolsVersion = 7.2.1; + }; EEBCC9D719CC627D0083B827 = { CreatedOnToolsVersion = 6.0; }; @@ -403,6 +480,7 @@ EEBCC9E119CC627D0083B827 /* SnapKit iOS Tests */, 537DCEAE1C35D90A00B5B899 /* SnapKit tvOS Tests */, EECDB3831AC0C9D4006BBC11 /* SnapKit OSX Tests */, + 56A0DC081C859E30005973AB /* Example-iOS */, ); }; /* End PBXProject section */ @@ -422,6 +500,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 56A0DC071C859E30005973AB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 56A0DC161C859E30005973AB /* LaunchScreen.storyboard in Resources */, + 56A0DC131C859E30005973AB /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; EEBCC9D619CC627D0083B827 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -480,6 +567,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 56A0DC051C859E30005973AB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 56A0DC221C859F15005973AB /* AppDelegate.swift in Sources */, + 56A0DC0E1C859E30005973AB /* ListViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; EEBCC9D319CC627D0083B827 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -536,6 +632,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 56A0DC1F1C859E9A005973AB /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = EEBCC9D719CC627D0083B827 /* SnapKit iOS */; + targetProxy = 56A0DC1E1C859E9A005973AB /* PBXContainerItemProxy */; + }; EECDB3871AC0C9D4006BBC11 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = EECDB3791AC0C9D4006BBC11 /* SnapKit OSX */; @@ -543,6 +644,17 @@ }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + 56A0DC141C859E30005973AB /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 56A0DC151C859E30005973AB /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 537DCE971C35CC8800B5B899 /* Debug */ = { isa = XCBuildConfiguration; @@ -622,6 +734,38 @@ }; name = Release; }; + 56A0DC181C859E30005973AB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEBUG_INFORMATION_FORMAT = dwarf; + EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Example-iOS/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.Example-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 56A0DC191C859E30005973AB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Example-iOS/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.Example-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; DDC9FDAF1981B4DD009612C7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -872,6 +1016,14 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 56A0DC1A1C859E30005973AB /* Build configuration list for PBXNativeTarget "Example-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 56A0DC181C859E30005973AB /* Debug */, + 56A0DC191C859E30005973AB /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; DDC9FD901981B4DD009612C7 /* Build configuration list for PBXProject "SnapKit" */ = { isa = XCConfigurationList; buildConfigurations = ( From 2cd154ed2a8b18571f64921d3fad45400ced72d9 Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 12:14:50 +0200 Subject: [PATCH 2/7] basic scrollview example --- Example-iOS/AppDelegate.swift | 12 ++++++++- Example-iOS/ListViewController.swift | 26 ++++++++++++++++--- .../demos/BasicUIScrollViewController.swift | 18 +++++++++++++ SnapKit.xcodeproj/project.pbxproj | 13 ++++++++++ 4 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 Example-iOS/demos/BasicUIScrollViewController.swift diff --git a/Example-iOS/AppDelegate.swift b/Example-iOS/AppDelegate.swift index 02e1dfa..fa17ea3 100644 --- a/Example-iOS/AppDelegate.swift +++ b/Example-iOS/AppDelegate.swift @@ -15,7 +15,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - // Override point for customization after application launch. + + self.window = UIWindow(frame: UIScreen.mainScreen().bounds) + + let listViewController:ListViewController = ListViewController() + let navigationController:UINavigationController = UINavigationController(rootViewController: listViewController); + + self.window!.rootViewController = navigationController; + + self.window!.backgroundColor = UIColor.whiteColor() + self.window!.makeKeyAndVisible() + return true } diff --git a/Example-iOS/ListViewController.swift b/Example-iOS/ListViewController.swift index 3160956..e5693cc 100644 --- a/Example-iOS/ListViewController.swift +++ b/Example-iOS/ListViewController.swift @@ -9,16 +9,36 @@ import UIKit import SnapKit -class ListViewController: UIViewController { +class ListViewController: UITableViewController { + let kCellIdentifier = "CellIdentifier" + let demos = ["Basic UIScrollView"] + override func viewDidLoad() { super.viewDidLoad() self.title = "SnapKit iOS Demos" + + self.tableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: kCellIdentifier) } + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier)! as UITableViewCell + + cell.textLabel?.text = demos[indexPath.row] + + return cell + } - - + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return demos.count + } + + override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + if indexPath.row == 0 { + let viewController = BasicUIScrollViewController() + navigationController?.pushViewController(viewController, animated: true) + } + } } diff --git a/Example-iOS/demos/BasicUIScrollViewController.swift b/Example-iOS/demos/BasicUIScrollViewController.swift new file mode 100644 index 0000000..91b2532 --- /dev/null +++ b/Example-iOS/demos/BasicUIScrollViewController.swift @@ -0,0 +1,18 @@ +// +// BasicUIScrollViewController.swift +// SnapKit +// +// Created by Spiros Gerokostas on 01/03/16. +// Copyright © 2016 SnapKit Team. All rights reserved. +// + +import UIKit + +class BasicUIScrollViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = UIColor.whiteColor() + } +} diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index d168c8d..0152fc1 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 56A0DC1C1C859E9A005973AB /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; 56A0DC1D1C859E9A005973AB /* SnapKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 56A0DC221C859F15005973AB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC211C859F15005973AB /* AppDelegate.swift */; }; + 56A0DC321C85A2C1005973AB /* BasicUIScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */; }; EE4910981B19A26000A54F1F /* ViewController+SnapKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */; }; EE4910991B19A40200A54F1F /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; EE94F6091AC0F10A008767FF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE94F6081AC0F10A008767FF /* UIKit.framework */; }; @@ -103,6 +104,7 @@ 56A0DC151C859E30005973AB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 56A0DC171C859E30005973AB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56A0DC211C859F15005973AB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicUIScrollViewController.swift; sourceTree = ""; }; EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ViewController+SnapKit.swift"; sourceTree = ""; }; EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -190,6 +192,7 @@ 56A0DC0A1C859E30005973AB /* Example-iOS */ = { isa = PBXGroup; children = ( + 56A0DC301C85A20E005973AB /* demos */, 56A0DC211C859F15005973AB /* AppDelegate.swift */, 56A0DC0D1C859E30005973AB /* ListViewController.swift */, 56A0DC121C859E30005973AB /* Assets.xcassets */, @@ -199,6 +202,14 @@ path = "Example-iOS"; sourceTree = ""; }; + 56A0DC301C85A20E005973AB /* demos */ = { + isa = PBXGroup; + children = ( + 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */, + ); + path = demos; + sourceTree = ""; + }; DDC9FD8C1981B4DD009612C7 = { isa = PBXGroup; children = ( @@ -572,6 +583,7 @@ buildActionMask = 2147483647; files = ( 56A0DC221C859F15005973AB /* AppDelegate.swift in Sources */, + 56A0DC321C85A2C1005973AB /* BasicUIScrollViewController.swift in Sources */, 56A0DC0E1C859E30005973AB /* ListViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1023,6 +1035,7 @@ 56A0DC191C859E30005973AB /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; DDC9FD901981B4DD009612C7 /* Build configuration list for PBXProject "SnapKit" */ = { isa = XCConfigurationList; From 60ebb0e45bb340ce5ee6a5490fd94e1fc245da7e Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 13:00:56 +0200 Subject: [PATCH 3/7] adding basic uiscrollview --- .../demos/BasicUIScrollViewController.swift | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Example-iOS/demos/BasicUIScrollViewController.swift b/Example-iOS/demos/BasicUIScrollViewController.swift index 91b2532..46b744f 100644 --- a/Example-iOS/demos/BasicUIScrollViewController.swift +++ b/Example-iOS/demos/BasicUIScrollViewController.swift @@ -10,9 +10,57 @@ import UIKit class BasicUIScrollViewController: UIViewController { + var didSetupConstraints = false + + let scrollView = UIScrollView() + let contentView = UIView() + + let label: UILabel = { + let label = UILabel() + label.backgroundColor = .blueColor() + label.numberOfLines = 0 + label.lineBreakMode = .ByClipping + label.textColor = .whiteColor() + label.text = NSLocalizedString("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum", comment: "") + return label + }() + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.whiteColor() + + view.addSubview(scrollView) + + contentView.backgroundColor = UIColor.redColor() + scrollView.addSubview(contentView) + contentView.addSubview(label) + + view.setNeedsUpdateConstraints() + } + + override func updateViewConstraints() { + + if (!didSetupConstraints) { + scrollView.snp_makeConstraints { (make) -> Void in + make.edges.equalTo(view).inset(UIEdgeInsetsZero) + } + + contentView.snp_makeConstraints { (make) -> Void in + make.edges.equalTo(scrollView).inset(UIEdgeInsetsZero) + make.width.equalTo(scrollView) + } + + label.snp_makeConstraints { (make) -> Void in + make.top.equalTo(contentView).inset(20) + make.leading.equalTo(contentView).inset(20) + make.trailing.equalTo(contentView).inset(20) + make.bottom.equalTo(contentView).inset(20) + } + + didSetupConstraints = true + } + + super.updateViewConstraints() } } From a2313430501f14b9c5d32bc16e420fc9c85e95ac Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 13:13:24 +0200 Subject: [PATCH 4/7] updates --- Example-iOS/ListViewController.swift | 5 +- .../demos/BasicUIScrollViewController.swift | 3 +- .../demos/SimpleLayoutViewController.swift | 46 +++++++++++++++++++ SnapKit.xcodeproj/project.pbxproj | 4 ++ 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 Example-iOS/demos/SimpleLayoutViewController.swift diff --git a/Example-iOS/ListViewController.swift b/Example-iOS/ListViewController.swift index e5693cc..5fccd7a 100644 --- a/Example-iOS/ListViewController.swift +++ b/Example-iOS/ListViewController.swift @@ -12,7 +12,7 @@ import SnapKit class ListViewController: UITableViewController { let kCellIdentifier = "CellIdentifier" - let demos = ["Basic UIScrollView"] + let demos = ["Simple Layout", "Basic UIScrollView"] override func viewDidLoad() { super.viewDidLoad() @@ -36,6 +36,9 @@ class ListViewController: UITableViewController { override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { if indexPath.row == 0 { + let viewController = SimpleLayoutViewController() + navigationController?.pushViewController(viewController, animated: true) + } else if indexPath.row == 1 { let viewController = BasicUIScrollViewController() navigationController?.pushViewController(viewController, animated: true) } diff --git a/Example-iOS/demos/BasicUIScrollViewController.swift b/Example-iOS/demos/BasicUIScrollViewController.swift index 46b744f..5ec3014 100644 --- a/Example-iOS/demos/BasicUIScrollViewController.swift +++ b/Example-iOS/demos/BasicUIScrollViewController.swift @@ -32,7 +32,7 @@ class BasicUIScrollViewController: UIViewController { view.addSubview(scrollView) - contentView.backgroundColor = UIColor.redColor() + contentView.backgroundColor = UIColor.lightGrayColor() scrollView.addSubview(contentView) contentView.addSubview(label) @@ -42,6 +42,7 @@ class BasicUIScrollViewController: UIViewController { override func updateViewConstraints() { if (!didSetupConstraints) { + scrollView.snp_makeConstraints { (make) -> Void in make.edges.equalTo(view).inset(UIEdgeInsetsZero) } diff --git a/Example-iOS/demos/SimpleLayoutViewController.swift b/Example-iOS/demos/SimpleLayoutViewController.swift new file mode 100644 index 0000000..d30f2a0 --- /dev/null +++ b/Example-iOS/demos/SimpleLayoutViewController.swift @@ -0,0 +1,46 @@ +// +// SimpleLayoutViewController.swift +// SnapKit +// +// Created by Spiros Gerokostas on 01/03/16. +// Copyright © 2016 SnapKit Team. All rights reserved. +// + +import UIKit + +class SimpleLayoutViewController: UIViewController { + + var didSetupConstraints = false + + let blackView: UIView = { + let view = UIView() + view.backgroundColor = .blackColor() + return view + }() + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = UIColor.whiteColor() + + view.addSubview(blackView) + + view.setNeedsUpdateConstraints() + } + + override func updateViewConstraints() { + + if (!didSetupConstraints) { + + blackView.snp_makeConstraints(closure: { (make) -> Void in + make.center.equalTo(view) + make.size.equalTo(CGSizeMake(100.0, 100.0)) + }) + + didSetupConstraints = true + } + + super.updateViewConstraints() + } + +} diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 0152fc1..4213671 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ 56A0DC1D1C859E9A005973AB /* SnapKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 56A0DC221C859F15005973AB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC211C859F15005973AB /* AppDelegate.swift */; }; 56A0DC321C85A2C1005973AB /* BasicUIScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */; }; + 56A0DC341C85AFBF005973AB /* SimpleLayoutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC331C85AFBF005973AB /* SimpleLayoutViewController.swift */; }; EE4910981B19A26000A54F1F /* ViewController+SnapKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */; }; EE4910991B19A40200A54F1F /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; EE94F6091AC0F10A008767FF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE94F6081AC0F10A008767FF /* UIKit.framework */; }; @@ -105,6 +106,7 @@ 56A0DC171C859E30005973AB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56A0DC211C859F15005973AB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicUIScrollViewController.swift; sourceTree = ""; }; + 56A0DC331C85AFBF005973AB /* SimpleLayoutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleLayoutViewController.swift; sourceTree = ""; }; EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ViewController+SnapKit.swift"; sourceTree = ""; }; EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -206,6 +208,7 @@ isa = PBXGroup; children = ( 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */, + 56A0DC331C85AFBF005973AB /* SimpleLayoutViewController.swift */, ); path = demos; sourceTree = ""; @@ -582,6 +585,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 56A0DC341C85AFBF005973AB /* SimpleLayoutViewController.swift in Sources */, 56A0DC221C859F15005973AB /* AppDelegate.swift in Sources */, 56A0DC321C85A2C1005973AB /* BasicUIScrollViewController.swift in Sources */, 56A0DC0E1C859E30005973AB /* ListViewController.swift in Sources */, From 98298bb1abec654a5fa8d942f90329f3cfdf5960 Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 13:16:44 +0200 Subject: [PATCH 5/7] updates --- Example-iOS/demos/SimpleLayoutViewController.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Example-iOS/demos/SimpleLayoutViewController.swift b/Example-iOS/demos/SimpleLayoutViewController.swift index d30f2a0..f5b0096 100644 --- a/Example-iOS/demos/SimpleLayoutViewController.swift +++ b/Example-iOS/demos/SimpleLayoutViewController.swift @@ -18,12 +18,19 @@ class SimpleLayoutViewController: UIViewController { return view }() + let redView: UIView = { + let view = UIView() + view.backgroundColor = .redColor() + return view + }() + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.whiteColor() view.addSubview(blackView) + view.addSubview(redView) view.setNeedsUpdateConstraints() } @@ -37,6 +44,11 @@ class SimpleLayoutViewController: UIViewController { make.size.equalTo(CGSizeMake(100.0, 100.0)) }) + redView.snp_makeConstraints(closure: { (make) -> Void in + make.top.equalTo(blackView.snp_bottom).offset(20.0) + make.size.equalTo(CGSizeMake(100.0, 100.0)) + }) + didSetupConstraints = true } From 259ee8b19f9da8e847d75a14b4f32ddf54911f59 Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 13:20:30 +0200 Subject: [PATCH 6/7] updates --- .../demos/SimpleLayoutViewController.swift | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Example-iOS/demos/SimpleLayoutViewController.swift b/Example-iOS/demos/SimpleLayoutViewController.swift index f5b0096..47cd001 100644 --- a/Example-iOS/demos/SimpleLayoutViewController.swift +++ b/Example-iOS/demos/SimpleLayoutViewController.swift @@ -24,6 +24,18 @@ class SimpleLayoutViewController: UIViewController { return view }() + let yellowView: UIView = { + let view = UIView() + view.backgroundColor = .yellowColor() + return view + }() + + let blueView: UIView = { + let view = UIView() + view.backgroundColor = .blueColor() + return view + }() + override func viewDidLoad() { super.viewDidLoad() @@ -31,6 +43,8 @@ class SimpleLayoutViewController: UIViewController { view.addSubview(blackView) view.addSubview(redView) + view.addSubview(yellowView) + view.addSubview(blueView) view.setNeedsUpdateConstraints() } @@ -46,6 +60,19 @@ class SimpleLayoutViewController: UIViewController { redView.snp_makeConstraints(closure: { (make) -> Void in make.top.equalTo(blackView.snp_bottom).offset(20.0) + make.left.equalTo(20.0) + make.size.equalTo(CGSizeMake(100.0, 100.0)) + }) + + yellowView.snp_makeConstraints(closure: { (make) -> Void in + make.top.equalTo(blackView.snp_bottom).offset(20.0) + make.left.equalTo(blackView.snp_right).offset(20.0) + make.size.equalTo(CGSizeMake(100.0, 100.0)) + }) + + blueView.snp_makeConstraints(closure: { (make) -> Void in + make.bottom.equalTo(blackView.snp_top).offset(0.0) + make.left.equalTo(blackView.snp_right).offset(20.0) make.size.equalTo(CGSizeMake(100.0, 100.0)) }) From c25dc8f12c2c776ddb2531222a30bdce4f9fa12a Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 13:23:33 +0200 Subject: [PATCH 7/7] fixes --- .../demos/BasicUIScrollViewController.swift | 2 +- .../demos/SimpleLayoutViewController.swift | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Example-iOS/demos/BasicUIScrollViewController.swift b/Example-iOS/demos/BasicUIScrollViewController.swift index 5ec3014..09fa0ae 100644 --- a/Example-iOS/demos/BasicUIScrollViewController.swift +++ b/Example-iOS/demos/BasicUIScrollViewController.swift @@ -21,7 +21,7 @@ class BasicUIScrollViewController: UIViewController { label.numberOfLines = 0 label.lineBreakMode = .ByClipping label.textColor = .whiteColor() - label.text = NSLocalizedString("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum", comment: "") + label.text = NSLocalizedString("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", comment: "") return label }() diff --git a/Example-iOS/demos/SimpleLayoutViewController.swift b/Example-iOS/demos/SimpleLayoutViewController.swift index 47cd001..414d0d6 100644 --- a/Example-iOS/demos/SimpleLayoutViewController.swift +++ b/Example-iOS/demos/SimpleLayoutViewController.swift @@ -36,6 +36,12 @@ class SimpleLayoutViewController: UIViewController { return view }() + let greenView: UIView = { + let view = UIView() + view.backgroundColor = .greenColor() + return view + }() + override func viewDidLoad() { super.viewDidLoad() @@ -45,6 +51,7 @@ class SimpleLayoutViewController: UIViewController { view.addSubview(redView) view.addSubview(yellowView) view.addSubview(blueView) + view.addSubview(greenView) view.setNeedsUpdateConstraints() } @@ -71,11 +78,17 @@ class SimpleLayoutViewController: UIViewController { }) blueView.snp_makeConstraints(closure: { (make) -> Void in - make.bottom.equalTo(blackView.snp_top).offset(0.0) + make.bottom.equalTo(blackView.snp_top).offset(-20.0) make.left.equalTo(blackView.snp_right).offset(20.0) make.size.equalTo(CGSizeMake(100.0, 100.0)) }) + greenView.snp_makeConstraints(closure: { (make) -> Void in + make.bottom.equalTo(blackView.snp_top).offset(-20.0) + make.right.equalTo(blackView.snp_left).offset(-20.0) + make.size.equalTo(CGSizeMake(100.0, 100.0)) + }) + didSetupConstraints = true }