Last active
August 23, 2023 03:15
-
-
Save Jon-Schneider/82b00edc6312296ddc0b3e32153f8f40 to your computer and use it in GitHub Desktop.
Programmatic UISplitViewController Example
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
// | |
// 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