0

I am creating a playground live view of a navigation controller with a single view controller.

import UIKit
import PlaygroundSupport

final class ViewController: UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()

    title = "View Controller"
  }
}

let viewController = ViewController()
let navigationController = UINavigationController(rootViewController: viewController)

PlaygroundPage.current.liveView = navigationController

The expected result is to have the navigation controller fully visible. Ideally, the frame would be an iPhone size, however, it's not necessary.

However, the result is clipped in the Playground Live View. See the following screenshot.

Playground live view

Is there a workaround to this behavior? Xcode version Version 12.5

Ilias Karim
  • 4,798
  • 3
  • 38
  • 60

1 Answers1

0

One solution is to use the navigation controller's view property. I.e.

PlaygroundPage.current.liveView = UINavigationController(rootViewController: controller).view
Ilias Karim
  • 4,798
  • 3
  • 38
  • 60