Skip to content

Instantly share code, notes, and snippets.

@Jon-Schneider
Last active August 23, 2023 03:15
Show Gist options
  • Save Jon-Schneider/82b00edc6312296ddc0b3e32153f8f40 to your computer and use it in GitHub Desktop.
Save Jon-Schneider/82b00edc6312296ddc0b3e32153f8f40 to your computer and use it in GitHub Desktop.
Programmatic UISplitViewController Example
//
// ViewController.swift
// SplitView
//
// Created by Jon Schneider on 8/21/23.
//
import UIKit
class SplitViewController: UISplitViewController {
let firstVC = {
let vc = UIViewController()
vc.view.backgroundColor = .gray
return vc
}()
let secondVC = {
let vc = UIViewController()
vc.view.backgroundColor = .cyan
return vc
}()
let thirdVC = {
let vc = UIViewController()
vc.view.backgroundColor = .orange
return vc
}()
override func viewDidLoad() {
super.viewDidLoad()
setViewController(firstVC, for: .primary)
if style == .doubleColumn {
setViewController(secondVC, for: .secondary)
} else if style == .tripleColumn {
setViewController(secondVC, for: .supplementary)
setViewController(thirdVC, for: .secondary)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment