How to hide UINavigationBar 1px bottom line

后端 未结 30 2504
不知归路
不知归路 2020-11-22 08:58

I have an app that sometimes needs its navigation bar to blend in with the content.

Does anyone know how to get rid of or to change color of this annoying little ba

30条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 09:42

    As of iOS 13 there is a system API to set or remove the shadow

    UIKit uses shadowImage and the shadowColor property to determine the shadow's appearance. When shadowImage is nil, the bar displays a default shadow tinted according to the value in the shadowColor property. If shadowColor is nil or contains the clearColor color, the bar displays no shadow.

        let appearance = UINavigationBarAppearance()
        appearance.shadowImage = nil
        appearance.shadowColor = nil
        navigationController.navigationBar.standardAppearance = appearance
    

    https://developer.apple.com/documentation/uikit/uibarappearance/3198009-shadowimage

提交回复
热议问题