This commit is contained in:
Spiros Gerokostas 2016-03-01 13:13:24 +02:00
parent 60ebb0e45b
commit a231343050
4 changed files with 56 additions and 2 deletions

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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()
}
}

View File

@ -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 = "<group>"; };
56A0DC211C859F15005973AB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicUIScrollViewController.swift; sourceTree = "<group>"; };
56A0DC331C85AFBF005973AB /* SimpleLayoutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleLayoutViewController.swift; sourceTree = "<group>"; };
EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ViewController+SnapKit.swift"; sourceTree = "<group>"; };
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 = "<group>";
@ -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 */,