sag*_*444 30
只需在8.1模拟器上查看并获得与您的图片非常相似的结果
let bar:UINavigationBar! = self.navigationController?.navigationBar
bar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
bar.shadowImage = UIImage()
bar.backgroundColor = UIColor(red: 0.0, green: 0.3, blue: 0.5, alpha: 0.3)
Run Code Online (Sandbox Code Playgroud)
这里的主要观点是带有alpha的背景颜色.
检查附图,也许我错过了什么?
nic*_*aef 13
要全局设置此样式,请使用UIAppearance API.在AppDelegate中application:didFinishLaunchingWithOptions:
添加以下代码:
// 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.3, blue: 0.5, alpha: 0.3)
// Set translucent. (Default value is already true, so this can be removed if desired.)
UINavigationBar.appearance().translucent = true
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
15804 次 |
最近记录: |