Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. //
  2. // System Colors Playground
  3. // fivestars.blog
  4. //
  5. // Created by Federico Zanetello on 9/6/19.
  6. //
  7.  
  8. import UIKit
  9. import PlaygroundSupport
  10.  
  11. final class ContainerViewController: UIViewController {
  12.  
  13. lazy var lightViewController: ColorViewController = {
  14. $0.overrideUserInterfaceStyle = .light
  15. return $0
  16. }(ColorViewController())
  17.  
  18. lazy var darkViewController: ColorViewController = {
  19. $0.overrideUserInterfaceStyle = .dark
  20. return $0
  21. }(ColorViewController())
  22.  
  23. override func loadView() {
  24. super.loadView()
  25.  
  26. let stackView = UIStackView()
  27. stackView.distribution = .fillEqually
  28. stackView.axis = .vertical
  29.  
  30. stackView.addArrangedSubview(lightViewController.view)
  31. stackView.addArrangedSubview(darkViewController.view)
  32.  
  33. view = stackView
  34. }
  35. }
  36.  
  37. class ColorViewController : UIViewController {
  38. private let systemColors: [UIColor] = [.systemGray,
  39. .systemGray2,
  40. .systemGray3,
  41. .systemGray4,
  42. .systemGray5,
  43. .systemGray6]
  44. override func loadView() {
  45. super.loadView()
  46.  
  47. let horizontalStackView = UIStackView()
  48. horizontalStackView.distribution = .fillEqually
  49.  
  50. for color in systemColors {
  51. let view = UIView()
  52. view.backgroundColor = color
  53. horizontalStackView.addArrangedSubview(view)
  54. }
  55.  
  56. view = horizontalStackView
  57. }
  58. }
  59.  
  60. let containerViewController = ContainerViewController()
  61. containerViewController.preferredContentSize = CGSize(width: 600, height: 100)
  62. PlaygroundPage.current.liveView = containerViewController
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement