Commit eb4851dc by Daniel Dahan

updated MaterialLayout project to Layout project

parent d7c78951
......@@ -14,7 +14,7 @@
location = "group:Programmatic/MaterialIcon/MaterialIcon.xcodeproj">
</FileRef>
<FileRef
location = "group:Programmatic/MaterialLayout/MaterialLayout.xcodeproj">
location = "group:Programmatic/Layout/Layout.xcodeproj">
</FileRef>
<FileRef
location = "group:Programmatic/Grid/Grid.xcodeproj">
......
......@@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:MaterialLayout.xcodeproj">
location = "self:Layout.xcodeproj">
</FileRef>
</Workspace>
......@@ -35,7 +35,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = ViewController()
......
......@@ -31,9 +31,9 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
......
......@@ -30,8 +30,8 @@
/**
Layout is an excellent tool to ease the use of AutoLayout. The following
examples demonstrate laying out a collection of UILabel objects, both vertically
and horizontally.
examples demonstrate laying out a collection of UILabel objects in the vertical,
horizontal, anc center positions.
*/
import UIKit
......@@ -41,9 +41,8 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
// prepareAlignToParentHorizontallyExample()
// prepareAlignToParentVerticallyExample()
prepareCenterExample()
prepareAlignToParentHorizontallyAndVerticallyExample()
// prepareCenterExample()
}
/// General preparation statements.
......@@ -52,7 +51,7 @@ class ViewController: UIViewController {
}
/// Layout views horizontally with equal width.
private func prepareAlignToParentHorizontallyExample() {
private func prepareAlignToParentHorizontallyAndVerticallyExample() {
let label1: UILabel = UILabel()
label1.backgroundColor = MaterialColor.red.base
label1.text = "A"
......@@ -88,76 +87,39 @@ class ViewController: UIViewController {
}
}
/// Layout views vertically with equal height.
private func prepareAlignToParentVerticallyExample() {
let label1: UILabel = UILabel()
label1.backgroundColor = MaterialColor.red.base
label1.text = "A"
label1.textAlignment = .Center
// Lays out test views to the center of different axes
private func prepareCenterExample() {
let length: CGFloat = 100
let label2: UILabel = UILabel()
label2.backgroundColor = MaterialColor.green.base
label2.text = "B"
label2.textAlignment = .Center
let label3: UILabel = UILabel()
label3.backgroundColor = MaterialColor.blue.base
label3.text = "C"
label3.textAlignment = .Center
let label4: UILabel = UILabel()
label4.backgroundColor = MaterialColor.yellow.base
label4.text = "D"
label4.textAlignment = .Center
let children: Array<UIView> = [label1, label2, label3, label4]
// Align the labels vertically with an equal height.
view.layout.vertically(children, top: 100, bottom: 100, spacing: 10)
// Align the labels horizontally with an equal width.
view.layout.horizontally(children, left: 100, right: 100)
// Print out the dimensions of the labels.
for v in children {
v.layoutIfNeeded()
print(v.frame)
}
}
// Lays out test views to the center of different axes
private func prepareCenterExample() {
let length: CGFloat = 100
let labelCX = UILabel()
labelCX.backgroundColor = MaterialColor.grey.base
labelCX.text = "centerX"
labelCX.textAlignment = .Center
labelCX.layer.cornerRadius = length / 2.0
labelCX.clipsToBounds = true
let labelCX = UILabel()
labelCX.backgroundColor = MaterialColor.grey.base
labelCX.text = "centerX"
labelCX.textAlignment = .Center
labelCX.layer.cornerRadius = length / 2.0
labelCX.clipsToBounds = true
view.layout.size(labelCX, width: length, height: length)
view.layout.centerHorizontally(labelCX)
let labelCY = UILabel()
labelCY.backgroundColor = MaterialColor.grey.base
labelCY.text = "centerY"
labelCY.textAlignment = .Center
labelCY.layer.cornerRadius = length / 2.0
labelCY.clipsToBounds = true
view.layout.centerHorizontally(labelCX)
let labelCY = UILabel()
labelCY.backgroundColor = MaterialColor.grey.base
labelCY.text = "centerY"
labelCY.textAlignment = .Center
labelCY.layer.cornerRadius = length / 2.0
labelCY.clipsToBounds = true
view.layout.size(labelCY, width: length, height: length)
view.layout.centerVertically(labelCY)
let labelCXY = UILabel()
labelCXY.backgroundColor = MaterialColor.grey.base
labelCXY.text = "centerXY"
labelCXY.textAlignment = .Center
labelCXY.layer.cornerRadius = length / 2.0
labelCXY.clipsToBounds = true
let labelCXY = UILabel()
labelCXY.backgroundColor = MaterialColor.grey.base
labelCXY.text = "centerXY"
labelCXY.textAlignment = .Center
labelCXY.layer.cornerRadius = length / 2.0
labelCXY.clipsToBounds = true
view.layout.size(labelCXY, width: length, height: length)
view.layout.center(labelCXY)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment