How to make the incall overlay not push the ui downwards

后端 未结 2 1483
庸人自扰
庸人自扰 2021-01-15 16:16

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

The extended height of the status bar pushes m

相关标签:
2条回答
  • 2021-01-15 16:24

    I used use "Vertical space - Bottom layout Guide - Button". This way, a button I have on the bottom of the screen stays in the same place when there is an in call bar and if a different screen size is used (3.5inch or 4icnh).

    0 讨论(0)
  • 2021-01-15 16:50

    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.

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

    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;
    }
    
    0 讨论(0)
提交回复
热议问题