您的位置:首页 > 移动开发 > IOS开发

iOS 来电 导致布局变化的解决方案

2015-11-01 15:56 609 查看
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(statusFrameChanged:)
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];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: