Search code examples
swiftuinavigationbariphone-xsafearealayoutguide

Update custom navigationBar trasparent Image autolayout Iphone X?


Tell me how to do it custom navigation bar trasparent Iphone X?Here is the picture that I want. Here is my code that I did. But when I fix the picture of the changes does not happen. The transparent navigationBar and status bar become ordinary.All my data are shifted which I fixed. Tell me what else you need to add so that I also had it?

my code : ViewController

override func viewDidLoad() {
    super.viewDidLoad()

    UIApplication.shared.statusBarStyle = .default


    // Do any additional setup after loading the view.
}

AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {


        UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .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().isTranslucent = true

        // Override point for customization after application launch.

        UITabBar.appearance().tintColor = UIColor(red:1.00, green:0.88, blue:0.00, alpha:1.0)
        UITabBar.appearance().barTintColor = UIColor.black

        UIApplication.shared.statusBarStyle = .lightContent        

}

enter image description here

enter image description here


Solution

  • You need to also add the UIStatusBarStyle key to the Info.plist and set the value to .lightContent