UINavigationBar 不在 Playground 中显示项目部件

UINavigationBar doesn’t display item parts in Playground

我正在 Playground 中的 UINavigationBar API 周围玩耍。下面的代码只生成一个空的导航栏,没有标题和后退按钮。

import UIKit
import PlaygroundSupport

let nav = UINavigationBar(frame: CGRect(x: 0, y: 0, width: 342, height: 50))

nav.isTranslucent = false

let item = UINavigationItem(title: "Hello")
item.leftBarButtonItem = UIBarButtonItem(title: "Somewhere", style: .plain, target: nil, action: nil)

nav.pushItem(ni, animated: false)

适合我。您是否尝试打开实时视图?游乐场页面的liveView设置了吗?