2017-12-01 7 views
0

私はオートレイアウトと多くのレガシーコードを使用しない古いプロジェクトを持っています。私はプロジェクト全体のコードを書き直すまで、iPhone Xと互換性を持たせたいと思っています。私はNotchKitを使用することを考えましたが、期待される結果は得られません。 UIApplicationウィンドウのカスタムフレーム(フルスクリーンの直下)を定義する方法はありますか?そして、すべてのViewControllerはその境界を尊重しますか?UIWindow iPhoneXカスタム境界

答えて

0

あなたが使用安全AreaLayoutガイド

enter image description hereで確認する必要があり、迅速

ストーリーボードファイルで
if #available(iOS 11.0, *) { 
    let window = UIApplication.shared.keyWindow 
    let topPadding = window?.safeAreaInsets.top 
    let bottomPadding = window?.safeAreaInsets.bottom 
    let leftPadding = window?.safeAreaInsets.left 
    let rightPadding = window?.safeAreaInsets.right 
} 
のObjective Cで

if (@available(iOS 11.0, *)) { 
    UIWindow *window = UIApplication.sharedApplication.keyWindow; 
    CGFloat topPadding = window.safeAreaInsets.top; 
    CGFloat bottomPadding = window.safeAreaInsets.bottom; 
    CGFloat leftPadding = window.safeAreaInsets.left; 
    CGFloat rightPadding = window.safeAreaInsets.right; 
} 
+0

作成したすべてのUIViewでパディングを使用する必要がありますか?それは私が持っていた目的ではありません。 –

+0

これを見てくださいhttps://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/ – user6788419

+0

私の目的を果たしていません。私が望むのは、subview.frame = CGRectMake(leftPadding、topPadding、width、height)にsubview.frame = CGRectMake(0,0、width、height)のようなリーチとすべての呼び出しを置き換えないことです。 –

0

でiPhoneX

のパディングを見つけることができます