如何使用后退按钮使导航栏透明,并且 webView 将显示到状态栏的边缘
How to make navigation bar transparent with a back button and the webView will display until the edge of the status bar
如何使用后退按钮使导航栏透明,并且 webView 会一直显示到状态栏的边缘。
我的webview约束都设置在Superview
的边缘
我试过了this but I got the following results.
我也在 appdelegate.m
尝试了以下代码
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
navigationBarAppearance.backgroundColor = [UIColor clearColor];
[navigationBarAppearance setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
navigationBarAppearance.shadowImage = [[UIImage alloc] init];
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
但是 webview 直到状态栏也不会加载。它会停在导航栏上。
我运行没主意,请帮忙。
显示 WebView 约束,只是不会显示通过导航栏。
您可以通过以下方式获取导航栏高度,这适用于所有屏幕
let height = self.navigationController.navigationBar.frame.size.height
并且您需要将 webview 的顶部约束设置为 -ve 到此值。首先,引用顶部约束说
@IBoutlet weak var topRefWebView:NSLayoutConstraint!
在视图中设置它的值会出现
let height = self.navigationController.navigationBar.frame.size.height
topRefWebView = -1 * height
如何使用后退按钮使导航栏透明,并且 webView 会一直显示到状态栏的边缘。
我的webview约束都设置在Superview
我试过了this but I got the following results.
我也在 appdelegate.m
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
navigationBarAppearance.backgroundColor = [UIColor clearColor];
[navigationBarAppearance setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
navigationBarAppearance.shadowImage = [[UIImage alloc] init];
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
但是 webview 直到状态栏也不会加载。它会停在导航栏上。
我运行没主意,请帮忙。
显示 WebView 约束,只是不会显示通过导航栏。
您可以通过以下方式获取导航栏高度,这适用于所有屏幕
let height = self.navigationController.navigationBar.frame.size.height
并且您需要将 webview 的顶部约束设置为 -ve 到此值。首先,引用顶部约束说
@IBoutlet weak var topRefWebView:NSLayoutConstraint!
在视图中设置它的值会出现
let height = self.navigationController.navigationBar.frame.size.height
topRefWebView = -1 * height