gpt4 book ai didi

ios - swift 3 : How to set up UINavigationBar setBackgroundImage in AppDelegate

转载 作者:搜寻专家 更新时间:2023-10-31 22:05:58 24 4
gpt4 key购买 nike

我最近从 Swift 2 迁移到 Swift 3,我被困在一个部分。在我的 AppDelegate 中,我设置了 UINavigationBar 的默认设置,如下所示。我面临的挑战是 setBackgroundImage 在 Swift 3 中不再被识别,我找不到替代方案。

有没有人遇到同样的问题并且能够解决它?

    let turquoiseBackgroundImage:UIImage = UIImage(named: "navigationBarTurqoise")!


**// TODO Below is not working with Swift 3
UINavigationBar.appearance().setBackgroundImage(turquoiseBackgroundImage, forBarPosition: .Default)**


// Set up Back button to be white in Navigation bar
UINavigationBar.appearance().barStyle = UIBarStyle.default
UINavigationBar.appearance().tintColor = UIColor.white

// Font Name and Size of Title in Navigation Bar
if let font = UIFont(name: "TitilliumWeb-Light", size: 20) {
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName : font, NSForegroundColorAttributeName : UIColor.white]
}

// Remove hairline between navigation bar and anything below such as search bar
UINavigationBar.appearance().shadowImage = UIImage()

// Set up status bar (battery, time, etc.) to white
UIApplication.shared.statusBarStyle = .lightContent

最佳答案

UINavigationBar.appearance().setBackgroundImage(turquoiseBackgroundImage, forBarPosition: .Default)

像这样重写代码

UINavigationBar.appearance().setBackgroundImage(turquoiseBackgroundImage, for: .default)

关于ios - swift 3 : How to set up UINavigationBar setBackgroundImage in AppDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39339670/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com