我正在尝试按以下方式设置我的应用,但是我无法让我的导航栏达到此级别的不透明度
我使用以下代码设置导航栏的样式:
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,我仍然只能得到以下结果:
是否有可能实现如此低的不透明度?
答案 0 :(得分:2)
这是我发现的最佳方式。您只需将其粘贴到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
}