Last active
June 18, 2019 04:10
-
-
Save zntfdr/c21da4fb2bc60c27a6c7cd0227543f8a to your computer and use it in GitHub Desktop.
A Playground showcasing the iOS 13 system colors grayscale
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] = [.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