如何使incall覆盖不向下推ui [英] How to make the incall overlay not push the ui downwards

查看:102
本文介绍了如何使incall覆盖不向下推ui的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iOS应用程序。它很棒。
除非用户有热点或正在通话但呼叫应用程序已最小化

I have an iOS app. It works great. Except when the user has a hotspot on or is in a call but the call app is minimised

状态栏的扩展高度会推动我的ui,让它的一部分消失,底部是

The extended height of the status bar pushes my ui down, making part of it disappear, at the bottom.

我希望这个扩展栏覆盖屏幕顶部而不是向下推ui。

I want this extended bar to overlay the top of the screen and not push the ui downwards.

我如何实现这一目标?

推荐答案

最简单的解决方案是制作确保您的视图的 spring-and-struts Autolayout 属性允许压缩或扩展视图,如果你有一些复杂的UI然后你可以实现 UIApplicationWillChangeStatusBarFrameNotification 观察者。

The Simplest Solution is to make sure that your view's springs-and-struts or Autolayout properties allow for compression or expansion of the view , If you have some complex UI then you can implement UIApplicationWillChangeStatusBarFrameNotification observer.

你可以处理 UIApplicationWillChangeStatusBarFrameNotification UIApplicationDidChangeStatusBarOrientationNotification 通知会告诉您状态栏的新大小。

You can handle the UIApplicationWillChangeStatusBarFrameNotification and UIApplicationDidChangeStatusBarOrientationNotification notifications which will tell you the new size of the status bar.

如果你打算使用at在视图上进行ransform以处理调整大小,您可以在视图控制器中实现-viewWillLayoutSubviews(可能在公共基类中),以在视图控制器的根视图上设置转换。

If you are intent on using a transform on your view to handle resizing, you can implement -viewWillLayoutSubviews in your view controllers (probably in a common base class) to set a transform on the root view of the view controller.

-(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;
}

这篇关于如何使incall覆盖不向下推ui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆