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) 獲取
相關文章
- 《iOS 11 安全區域適配總結》iOS
- Android 劉海屏適配Android
- Android 劉海屏適配總結Android
- 微信小程式吸底區域適配iPhone X微信小程式iPhone
- Android O, P 劉海屏及全面屏適配Android
- iOS11 適配iOS
- Flutter適配安卓劉海、水滴屏顯示全屏Flutter安卓
- Android P 劉海屏適配全攻略Android
- iOS11適配詳解iOS
- Android劉海屏適配全方案(華為、小米、Vivo、Oppo)Android
- pc大屏適配
- 適配iPhoneX & iOS11iPhoneiOS
- 移動端安全區域適配方案
- android全面屏適配Android
- iOS11適配遇到的問題iOS
- 小程式以及H5頁面上IphoneX底部安全區域小黑條適配問題H5iPhone
- vue3大屏適配Vue
- iOS11, Xcode9 and iphone X適配iOSXCodeiPhone
- 開發日常 適配iOS11和iPhone XiOSiPhone
- Android適配: 拉伸適配的缺點Android
- flutter 螢幕尺寸適配 字型大小適配Flutter
- iOS MJRefresh適配ios11以及iPhoneXiOSiPhone
- 適配iOS11, Xcode 9遇到的問題iOSXCode
- 一大波 Android 劉海屏來襲,全網\Maybe/最全適配技巧!Android
- Flutter SafeArea - 異形屏適配利器Flutter
- Android華為凹口屏適配小結Android
- 京東小程式摺疊屏適配探索
- android實現底部彈出框與軟鍵盤衝突(全面屏虛擬鍵適配)Android
- Android懸浮框的適配問題Android
- Android適配Android
- iOS 11適配iOS
- https適配HTTP
- 適配iphone XiPhone
- android螢幕適配三:通過畫素密度適配Android
- Android螢幕適配(理論適配100%機型)Android
- Android全面屏虛擬導航欄適配Android
- Android APP全面屏適配技術要點AndroidAPP
- Android錄製視訊的全面屏適配Android