我只是在没有更多故事板的情况下进入程序化vc,而且我正在跟随Brian Voong的YouTube LetsBuildThatApp获取指导https://youtu.be/NJxb7EKXF3U?list=PL0dzCUj1L5JHDWIO3x4wePhD8G4d1Fa6N。
我遵循了所有指示,出于某种原因,当我启动我的应用程序时,我在屏幕上看到了这种浅灰色的阴霾,我无法弄清楚为什么?我可以隐约看到导航标题和蓝色背景,但它被褪色层覆盖。
第1步: 我删除了我的故事板文件并在“我删除的部署信息”下删除了“常规”选项卡" Main"来自主界面。
第2步: 我将ProjectNavigator文件更改为FeedController,然后相应地更改了文件
import UIKit
class FeedController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "Facebook Feed"
collectionView?.backgroundColor = UIColor.white
}
}
第3步: 在AppDelegate中,我添加了一个NavVC并使FeedVC成为root用户,并使NavVC成为Window的根目录。我还更改了NavBar和StatusBar颜色
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let feedController = FeedController(collectionViewLayout: UICollectionViewFlowLayout())
let navVC = UINavigationController(rootViewController: feedController)
window?.rootViewController = navVC
UINavigationBar.appearance().tintColor = UIColor.blue
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
application.statusBarStyle = .lightContent
return true
}
第4步:
在info.plist
我将View controller-based status bar appearance
设置为NO
我无法弄清楚为什么我会在屏幕上出现这种浅灰色阴霾
我在这里缺少什么?
答案 0 :(得分:1)
看起来您正在配置tintColor而不是barTintColor。 tintColor更改导航按钮的颜色,barTintColor调整导航栏背景颜色。您可以观看此视频,了解有关自定义导航栏外观的更多详细信息。