如何使incall覆盖不向下推ui

我有一个iOS应用程序。 它工作很好。 除了当用户有一个热点或正在打电话,但通话应用程序是最小化

状态栏的延伸高度推动我的用户界面,使其中的一部分消失,在底部。

我想要这个扩展栏覆盖屏幕的顶部,而不是向下推动用户界面。

我如何做到这一点?

最简单的解决scheme是确保你的视图的springs-and-strutsAutolayout属性允许压缩或扩展视图。如果你有一些复杂的UI,那么你可以实现UIApplicationWillChangeStatusBarFrameNotification观察者。

您可以处理UIApplicationWillChangeStatusBarFrameNotificationUIApplicationDidChangeStatusBarOrientationNotification通知,它会告诉您状态栏的新大小。

如果您打算在视图上使用变换来处理resize,则可以在视图控制器(可能位于公共基类中)中实现-viewWillLayoutSubviews,以在视图控制器的根视图上设置变换。

 -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusFrameChanged:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil]; } -(void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarFrameNotification object:nil]; } - (void)statusFrameChanged:(NSNotification*)note { CGRect statusBarFrame = [note.userInfo[UIApplicationStatusBarFrameUserInfoKey] CGRectValue]; CGFloat statusHeight = statusBarFrame.size.height; UIScreen *screen = [UIScreen mainScreen]; CGRect viewRect = screen.bounds; viewRect.size.height -= statusHeight; viewRect.origin.y = statusHeight; self.view.frame = viewRect; [self.view setNeedsLayout]; } - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; CGRect baseFrame = self.view.frame; // 548.0 is the full height of the view. Update as necessary. CGFloat scale = self.view.frame.size.height / 548.0; [self.view setTransform:CGAffineTransformMakeScale(1.0, scale)]; self.view.frame = baseFrame; } 

我使用"Vertical space - Bottom layout Guide - Button" 。 这样,当有一个呼叫栏,并且使用不同的屏幕尺寸(3.5英寸或4厘米)时,屏幕底部的button将保持在同一个位置。