在 iphone 8 模拟器中,导航栏与 swift xcode 中的状态栏发生冲突
Navigation Bar colides with status bar in swift xcode for iphone 8 simulator
我正在开发一个 iphone 应用程序,它将兼容 iphone 6 到新的 iphone。
在此过程中,我遇到了一个问题,对于 iphone 8 模拟器,导航栏的高度太短,因此后退按钮与状态栏重叠,而在 iphone 11 中,一切看起来都很好。我将如何着手解决这个问题?如何使导航栏看起来像 iphone 11 中显示的那样? p.s。当用户按下上一页的按钮时,我只做了 link 来显示当前页面。当然,当我点击后退按钮时,我会返回。
在您的 AppDelegate 文件中,您可以添加:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
{
//(by default it is True)
UINavigationBar.appearance().isTranslucent = false
// it will prevent overlaping
}
或者您可以在 viewController
中添加此代码
self.edgesForExtendedLayout = UIRectEdge(rawValue: 0)
我正在开发一个 iphone 应用程序,它将兼容 iphone 6 到新的 iphone。
在此过程中,我遇到了一个问题,对于 iphone 8 模拟器,导航栏的高度太短,因此后退按钮与状态栏重叠,而在 iphone 11 中,一切看起来都很好。我将如何着手解决这个问题?如何使导航栏看起来像 iphone 11 中显示的那样? p.s。当用户按下上一页的按钮时,我只做了 link 来显示当前页面。当然,当我点击后退按钮时,我会返回。
在您的 AppDelegate 文件中,您可以添加:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
{
//(by default it is True)
UINavigationBar.appearance().isTranslucent = false
// it will prevent overlaping
}
或者您可以在 viewController
中添加此代码self.edgesForExtendedLayout = UIRectEdge(rawValue: 0)