Skip to content

Instantly share code, notes, and snippets.

@zntfdr
Last active November 14, 2019 10:33
Show Gist options
  • Save zntfdr/bb8173970414d4b4e90d3a6b18f01e4b to your computer and use it in GitHub Desktop.
Save zntfdr/bb8173970414d4b4e90d3a6b18f01e4b to your computer and use it in GitHub Desktop.
A Playground showcasing all the iOS 13 system colors
//
// 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