ios11 劉海屏 安全區域 適配 彈框區域適配
網上看了很多 自己的程式碼裡面最終還是採用了自己的辦法
我採用安全區域做
首先在基類自定義了個vkview 如果非SB或者xib做的話 就可以用到
- (UIView*)vkView {
if(!_vkView) {
if(@available(iOS11.0, *)) {
self.view.backgroundColor=VKHexColor(app_White_Color);
_vkView= [[UIViewalloc]init];
[self.viewaddSubview:_vkView];
[_vkViewmas_makeConstraints:^(MASConstraintMaker*make) {
make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop);
make.bottom.mas_equalTo(self.view.mas_safeAreaLayoutGuideBottom);
make.left.mas_equalTo(self.view.mas_safeAreaLayoutGuideLeft);
make.right.mas_equalTo(self.view.mas_safeAreaLayoutGuideRight);
}];
}else{
//適配狀態列
if (self.navigationController.navigationBarHidden || !self.navigationController) {
self.view.backgroundColor=VKHexColor(app_White_Color);
_vkView= [[UIViewalloc]init];
[self.viewaddSubview:_vkView];
[_vkViewmas_makeConstraints:^(MASConstraintMaker*make) {
make.top.mas_equalTo(self.view).offset(20);
make.bottom.left.right.mas_equalTo(self.view);
}];
}else{
_vkView=self.view;
}
}
_vkView.backgroundColor = VKHexColor(app_White_Color);
}
return _vkView;
}
用vkview的時候 記得在點語法之前 告知導航欄隱藏的情況
二 ,劉海屏有時候需要判斷
1》window.safeAreaLayoutGuide.layoutFrame.size.height !=kScreenHeight kScreenHeight是巨集屏高
2》[UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom > 0
三,有時候需要彈框 需要精確定位
self是封裝的彈框view
[[[UIApplication sharedApplication].keyWindow.subviews objectAtIndex:0] addSubview:self];
if(@available(iOS11.0, *)) {
[selfmas_makeConstraints:^(MASConstraintMaker*make) {
make.top.mas_equalTo(_toPoint.y);
make.left.mas_equalTo([[UIApplication sharedApplication].keyWindow.subviews objectAtIndex:0].mas_safeAreaLayoutGuideLeft);
make.right.mas_equalTo([[UIApplication sharedApplication].keyWindow.subviews objectAtIndex:0].mas_safeAreaLayoutGuideRight);
make.bottom.mas_equalTo([[UIApplication sharedApplication].keyWindow.subviews objectAtIndex:0].mas_safeAreaLayoutGuideBottom);
}];
}else{
[selfmas_makeConstraints:^(MASConstraintMaker*make) {
make.top.mas_equalTo(_toPoint.y);
make.left.mas_equalTo([[UIApplication sharedApplication].keyWindow.subviews objectAtIndex:0].mas_left);
make.right.mas_equalTo([[UIApplication sharedApplication].keyWindow.subviews objectAtIndex:0].mas_right);
make.bottom.mas_equalTo([[UIApplication sharedApplication].keyWindow.subviews objectAtIndex:0].mas_bottom);
}];
}
其中topoint是
//獲取絕對高度
UIWindow*window = [[[UIApplicationsharedApplication]delegate]window];
CGRectrect = [weakSelf.segmentViewconvertRect:weakSelf.segmentView.boundstoView:window];
CGPointMake(0, rect.origin.y+rect.size.height) 獲取
相關文章
- Android 劉海屏適配Android
- Android 劉海屏適配總結Android
- Android O, P 劉海屏及全面屏適配Android
- Android P 劉海屏適配全攻略Android
- Flutter適配安卓劉海、水滴屏顯示全屏Flutter安卓
- Android劉海屏適配全方案(華為、小米、Vivo、Oppo)Android
- 微信小程式吸底區域適配iPhone X微信小程式iPhone
- android全面屏適配Android
- pc大屏適配
- 小程式以及H5頁面上IphoneX底部安全區域小黑條適配問題H5iPhone
- iOS11適配遇到的問題iOS
- iOS MJRefresh適配ios11以及iPhoneXiOSiPhone
- 移動端安全區域適配方案
- 一大波 Android 劉海屏來襲,全網\Maybe/最全適配技巧!Android
- vue3大屏適配Vue
- Android劉海屏、水滴屏全面屏適配方案Android
- Android適配: 拉伸適配的缺點Android
- Flutter SafeArea - 異形屏適配利器Flutter
- android實現底部彈出框與軟鍵盤衝突(全面屏虛擬鍵適配)Android
- flutter 螢幕尺寸適配 字型大小適配Flutter
- Android懸浮框的適配問題Android
- Android適配Android
- dimens適配
- iphoneX適配iPhone
- Android華為凹口屏適配小結Android
- Android螢幕適配(理論適配100%機型)Android
- WebView iPhoneX適配WebViewiPhone
- iphoneX,XsMax適配iPhone
- 裝置適配
- 適配問題
- 螢幕適配
- Android APP全面屏適配技術要點AndroidAPP
- Android全面屏虛擬導航欄適配Android
- 京東小程式摺疊屏適配探索
- Android錄製視訊的全面屏適配Android
- android螢幕適配三:通過畫素密度適配Android
- 移動端適配
- rem 適配佈局REM