Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LightDarkVC: UIViewController {
- override func viewDidLoad() {
- super.viewDidLoad()
- let stack = UIStackView()
- stack.axis = .vertical
- stack.spacing = 20
- stack.translatesAutoresizingMaskIntoConstraints = false
- view.addSubview(stack)
- let g = view.safeAreaLayoutGuide
- NSLayoutConstraint.activate([
- stack.topAnchor.constraint(equalTo: g.topAnchor, constant: 40.0),
- stack.leadingAnchor.constraint(equalTo: g.leadingAnchor, constant: 40.0),
- stack.trailingAnchor.constraint(equalTo: g.trailingAnchor, constant: -40.0),
- ])
- let font: UIFont = .systemFont(ofSize: 24.0, weight: .bold)
- var v: UILabel!
- v = UILabel()
- v.text = "Default"
- v.textAlignment = .center
- v.font = font
- stack.addArrangedSubview(v)
- v = UILabel()
- v.text = "Always Light"
- v.textAlignment = .center
- v.overrideUserInterfaceStyle = .light
- v.font = font
- stack.addArrangedSubview(v)
- v = UILabel()
- v.text = "Always Dark"
- v.textAlignment = .center
- v.overrideUserInterfaceStyle = .dark
- v.font = font
- stack.addArrangedSubview(v)
- v = UILabel()
- v.text = "Explicit Colors\nWhite Background\nBlack .textColor"
- v.textAlignment = .center
- v.numberOfLines = 0
- v.backgroundColor = .white
- v.textColor = .black
- v.font = font
- stack.addArrangedSubview(v)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement