无法更改导航栏的不透明度 [英] Unable to change navigation bar opacity
本文介绍了无法更改导航栏的不透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过以下方式设置应用样式,但是我无法使导航栏达到这种不透明级别
I am trying to style my app in the following way, however i am unable to get my navigation bar to reach this level of opacity
我使用以下代码来设置导航栏的样式:
I use the following code to style the navigation bar:
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,我仍然只能得到以下结果:
Even with the alpha set to 0.1, i still only get the following result:
是否可以实现如此低的不透明度?
Is it possible to achieve such a low opacity?
推荐答案
这是我找到的最好方法.您可以将其粘贴到appDelegate的didFinishLaunchingWithOptions方法中:
This is the best way that I've found. You can just paste it into your appDelegate's didFinishLaunchingWithOptions method:
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
}
这篇关于无法更改导航栏的不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文