-
Notifications
You must be signed in to change notification settings - Fork 730
Expand file tree
/
Copy pathTVApp.swift
More file actions
45 lines (37 loc) · 1.07 KB
/
TVApp.swift
File metadata and controls
45 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// TVApp.swift
// Example-tvOS
//
// Copyright (c) 2015 Mickey Reiss Fox
// https://github.com/PureLayout/PureLayout
//
//
import UIKit
import PureLayout
class TVViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let views = [UIColor.red, UIColor.green, UIColor.blue]
.map(TVButton.init)
views.forEach(self.view.addSubview)
(views as NSArray).autoDistributeViews(along: .horizontal, alignedTo: .horizontal, withFixedSpacing: 50)
views.forEach { view in
view.autoAlignAxis(toSuperviewAxis: .horizontal)
view.autoSetDimension(.height, toSize: 300)
}
}
}
@UIApplicationMain
class TVAppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
}
class TVButton : UIControl {
required init(color: UIColor) {
super.init(frame: CGRect.zero)
self.translatesAutoresizingMaskIntoConstraints = false
self.backgroundColor = color
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}