From a2313430501f14b9c5d32bc16e420fc9c85e95ac Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 13:13:24 +0200 Subject: [PATCH] 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 */,