版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。版权
CGFloat safeNum = 0; //判断版本 if (@available(iOS 11.0, *)) { //通过系统方法keyWindow来获取safeAreaInsets UIEdgeInsets safeArea = [[UIApplication sharedApplication] keyWindow].safeAreaInsets; safeNum = safeArea.bottom; }
//如果是iPhoneX 之类刘海屏底部的工具栏距离屏幕底部(底部安全距离) safeNum =34
//如果是iPhone8 之类的工具栏距离屏幕底部(底部安全距离) safeNum = 0