iOS 来电,网络分享导致页面偏移的解决方法

可以在 init 的时候添加监听

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(layoutControllerSubViews:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];

然后实现布局方法

- (void)layoutControllerSubViews:(NSNotification *)notification {
    NSDictionary * dicUserinfo = notification.userInfo;
    NSValue * value = [dicUserinfo objectForKey:UIApplicationStatusBarFrameUserInfoKey];
    CGRect rect = [value CGRectValue];

    [UIView animateWithDuration:0.35 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        _footerView.frame = CGRectMake(0, SCREEN_HEIGHT - 49 + 20 - CGRectGetHeight(rect), CGRectGetWidth(self.view.bounds), 49);
    } completion:^(BOOL finished) {

    }];
}

这个动画的时间试了很久才跟页面上下的动画一致,让页面不会跳动。