我在没有故事板的情况下工作。现在我遇到了一些问题,因为我不知道如何在一个屏幕上创建 NavigationBarController 和 tabBarController。 这是来自 SceneDelegate 的代码:
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions ) {
let vc = CollectionViewController.instantiate()
let navController = UINavigationController(rootViewController: vc)
guard let windowScene = (scene as? UIWindowScene) else {return}
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.rootViewController = navController
window?.makeKeyAndVisible()
}
}
我试图找到一些关于这个的信息,但没有成功。
让 navigationBar : UINavigationBar = UINavigationBar (frame: CGRect(x: 0, y: 58, width : width, height: 44))
navigationBar.tintColor = UIColor.black
在您的 tabbarcontroller viewdidload 中使用此代码