gpt4 book ai didi

swift - 无法更改导航栏不透明度

转载 作者:搜寻专家 更新时间:2023-11-01 07:26:56 24 4
gpt4 key购买 nike

我正在尝试以下列方式设置我的应用程序的样式,但是我无法让我的导航栏达到这种不透明度级别

enter image description here

我使用以下代码来设置导航栏的样式:

unc application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UINavigationBar.appearance().barTintColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.1)
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()]
}

即使将 alpha 设置为 0.1,我仍然只能得到以下结果:

enter image description here

有没有可能实现这么低的不透明度?

最佳答案

这是我找到的最好的方法。您可以将其粘贴到您的 appDelegate 的 didFinishLaunchingWithOptions 方法中:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
// Sets background to a blank/empty image
UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default)
// Sets shadow (line below the bar) to a blank image
UINavigationBar.appearance().shadowImage = UIImage()
// Sets the translucent background color
UINavigationBar.appearance().backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
// Set translucent. (Default value is already true, so this can be removed if desired.)
UINavigationBar.appearance().translucent = true

return true
}

关于swift - 无法更改导航栏不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35470666/

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