Make navigation bar transparent regarding below image in iOS 8.1

前端 未结 4 1200
后悔当初
后悔当初 2020-12-16 04:32

I try to set my navigation bar transparent regarding a image below this, something like the following image :

\"

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 05:16

    To set this style globally, use the UIAppearance APIs. In AppDelegate's application:didFinishLaunchingWithOptions: add the following code:

    // 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
    

提交回复
热议问题