【发布时间】:2017-06-27 19:49:05
【问题描述】:
我刚刚进入没有更多故事板的程序化 vc,我正在关注 Brian Voong 的 YouTube 的 LetsBuildThatApp 寻求指导 https://youtu.be/NJxb7EKXF3U?list=PL0dzCUj1L5JHDWIO3x4wePhD8G4d1Fa6N。
我按照所有指示进行操作,但由于某种原因,当我启动我的应用程序时,我的屏幕上出现了这种浅灰色的雾霾,我不知道为什么?我可以隐约看到导航标题和蓝色背景,但它被褪色层覆盖。
第 1 步: 我删除了我的故事板文件并拆分了部署信息下的常规选项卡我从主界面中删除了“主要”。
第 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 设为根,并将 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
我不知道为什么我的屏幕上出现这种浅灰色的雾霾
我在这里错过了什么?
【问题讨论】:
标签: uiviewcontroller uinavigationcontroller appdelegate uicolor rootviewcontroller