Skip to content

Instantly share code, notes, and snippets.

@zntfdr
Last active June 18, 2019 04:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zntfdr/c21da4fb2bc60c27a6c7cd0227543f8a to your computer and use it in GitHub Desktop.
Save zntfdr/c21da4fb2bc60c27a6c7cd0227543f8a to your computer and use it in GitHub Desktop.
A Playground showcasing the iOS 13 system colors grayscale
//
// 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] = [.systemGray,
.systemGray2,
.systemGray3,
.systemGray4,
.systemGray5,
.systemGray6]
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