我在菜单中有一个幻灯片,用于以编程方式创建UIViewController:
func showControllerForMenu(_ menus: Menu) {
let menuChoiceViewController = UIViewController()
menuChoiceViewController.view.backgroundColor = UIColor.white
menuChoiceViewController.navigationItem.title = menus.name
navigationController?.navigationBar.tintColor = UIColor.black
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.black]
navigationController?.pushViewController(menuChoiceViewController, animated: true)
}
这很好用,我想弄清楚的是如何子类化UIViewController以添加控件和功能。任何帮助将不胜感激。