【问题标题】:Extra padding is added below status-bar (in iOS) when adding color to status bar向状态栏添加颜色时,在状态栏下方添加额外的填充(在 iOS 中)
【发布时间】:2016-10-05 18:22:04
【问题描述】:
我正在使用 apache 插件:“cordova-plugin-statusbar”为我的应用主题着色状态栏。
以下是更改状态栏颜色的代码sn-p:
if(!StatusBar.isVisible){
StatusBar.show();
}
StatusBar.overlaysWebView(false);
StatusBar.backgroundColorByHexString(pinkColor); //pinkColor is defined
但这会在状态栏下方添加一个额外的填充。
【问题讨论】:
标签:
ios
cordova
statusbar
【解决方案1】:
我从status bar overlapping the view 得到解决方案,并根据我的要求进行了更改
我修改了“MainViewController.m”的“(void)viewWillAppear”:
- (void)viewWillAppear:(BOOL)animated
{
// View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
// you can do so here.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = [self.webView bounds];
viewBounds.size.height = viewBounds.size.height + 20;
self.webView.frame = viewBounds;
}
[super viewWillAppear:animated];
}
【解决方案2】:
我有另一个替代解决方案。作为一个插件,每次构建后在 XCode 中更改“MainViewController”是很烦人的。
状态栏插件包含CDVStatusBar.msrc/ios/下的文件
我已经编辑了-(void)resizeWebView:
if (!self.statusBarOverlaysWebView) {
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
statusBarFrame = [self invertFrameIfNeeded:statusBarFrame];
CGRect frame = self.webView.frame;
// frame.origin.y = statusBarFrame.size.height;
// frame.size.height -= statusBarFrame.size.height;
self.webView.frame = frame;
}
我已经注释掉了 WebView 框架大小的变化。
我希望这可以帮助遇到同样问题的人。
【解决方案3】:
在 ionic 2 的 app.module.ts 中
remove mode: 'md' in ios
import { IonicApp, IonicModule } from 'ionic-angular';
@NgModule({
declarations: [ MyApp ],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp, {
mode:md
}, {}
)],
bootstrap: [IonicApp],
entryComponents: [ MyApp ],
providers: []
})