Last active
November 14, 2019 10:33
-
-
Save zntfdr/bb8173970414d4b4e90d3a6b18f01e4b to your computer and use it in GitHub Desktop.
A Playground showcasing all the iOS 13 system colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// System Colors Playground | |
// fivestars.blog | |
// | |
// Created by Federico Zanetello on 9/6/19. | |
// | |
import UIKit | |
import PlaygroundSupport | |
final class ContainerViewController: UIViewController { | |
lazy var lightViewController: ColorViewController = { | |
$0.overrideUserInterfaceStyle = .light | |
return $0 | |
}(ColorViewController()) | |
lazy var darkViewController: ColorViewController = { | |
$0.overrideUserInterfaceStyle = .dark | |
return $0 | |
}(ColorViewController()) | |
override func loadView() { | |
super.loadView() | |
let stackView = UIStackView() | |
stackView.distribution = .fillEqually | |
stackView.axis = .vertical | |
stackView.addArrangedSubview(lightViewController.view) | |
stackView.addArrangedSubview(darkViewController.view) | |
view = stackView | |
} | |
} | |
class ColorViewController : UIViewController { | |
private let systemColors: [UIColor] = [.systemBlue, | |
.systemGray, | |
.systemGreen, | |
.systemIndigo, | |
.systemOrange, | |
.systemPink, | |
.systemPurple, | |
.systemRed, | |
.systemTeal, | |
.systemYellow] | |
override func loadView() { | |
super.loadView() | |
let horizontalStackView = UIStackView() | |
horizontalStackView.distribution = .fillEqually | |
for color in systemColors { | |
let view = UIView() | |
view.backgroundColor = color | |
horizontalStackView.addArrangedSubview(view) | |
} | |
view = horizontalStackView | |
} | |
} | |
let containerViewController = ContainerViewController() | |
containerViewController.preferredContentSize = CGSize(width: 600, height: 100) | |
PlaygroundPage.current.liveView = containerViewController |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment