Commit 24e9d3f1 authored by toby's avatar toby

use autolayout for background

parent db9aa7a7
......@@ -32,6 +32,7 @@
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
......
......@@ -126,12 +126,16 @@ class RootViewController: UIViewController {
autoViews["main"] = view
// Setup background
background = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
background.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
background = UIView()
autoViews["background"] = background!
background.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addSubview(background)
backgroundTransition = randomTransition()
background.backgroundColor = backgroundTransition.startColor
view.addSubview(background)
background.center = background.superview!.center
let vBackgroundConstraint = NSLayoutConstraint.constraintsWithVisualFormat("V:|-[background]-|", options: .AlignAllTop, metrics: nil, views: autoViews)
let hBackgroundConstraint = NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[background]-0-|", options: .AlignAllTop, metrics: nil, views: autoViews)
view.addConstraints(vBackgroundConstraint)
view.addConstraints(hBackgroundConstraint)
// Setup barrier
let barrier = UIView(frame: CGRectFromOrigin(view, 0, 40, 130, 20))
......
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