如何使用后退按钮使导航栏透明,并且 webView 将显示到状态栏的边缘。
我的webview约束都设置到Superview
的边缘
我试过了this但我得到了以下结果。
我还在 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约束,它只是不会通过导航栏显示。
最佳答案
您可以通过以下方式获取导航栏高度,这适用于所有屏幕
let height = self.navigationController.navigationBar.frame.size.height
并且您需要将 webview 的顶部约束设置为 -ve 为该值。首先,引用顶部约束 say
@IBoutlet weak var topRefWebView:NSLayoutConstraint!
在 View 中设置它的值会出现
let height = self.navigationController.navigationBar.frame.size.height
topRefWebView = -1 * height
关于ios - 如何使用后退按钮使导航栏透明,并且 webView 将显示到状态栏的边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49247229/