2017-10-23 27 views

答えて

1

はい、それは良い考えではありませんが、あなたの問題を解決することができます。

は、この手順に従います。

  • を有効にする「セーフゾーンレイアウト」
  • (すなわちbottomPaddingViewという名前を付けます)あなたのシートの色と同じ背景色、と(Programticallyまたは使用してストーリーボード)ビューを追加/作成します。
  • (以下の制約を使用して、 - 以下の制約は、コードの構造ではなく、単に制約/アンカーの関係を示す)位置を
    - bottomPaddingView.bottom = self.view.bottom
    - bottomPaddingView.trailing = self.view。 または bottomPaddingView.top =自己 - あなたは 'セーフゾーンレイアウト'
    を有効にしている場合bottomPaddingView.top = self.view.safeAreaLayoutConstraint.bottom // - bottomPaddingView.leading = self.view.leading
    -
    末尾.view.bottomLayoutguide //セーフエリアレイアウトを有効にしていない場合

あなたのbottomPaddingViewをフェードアニメーションによる行動の可視性に関して非表示/非表示にします。

1

ここに私の小さなエクステンションがあります。 「マジックナンバー」タグで追加されたビューにアクセスできないように改善を提案できる人がいらっしゃる場合 - ようこそ!

extension UIViewController { 

private static let insetBackgroundViewTag = 98721 //Cool number 

func paintSafeAreaBottomInset(withColor color: UIColor) { 
    guard #available(iOS 11.0, *) else { 
     return 
    } 
    if let insetView = view.viewWithTag(UIViewController.insetBackgroundViewTag) { 
     insetView.backgroundColor = color 
     return 
    } 

    let insetView = UIView(frame: .zero) 
    insetView.tag = UIViewController.insetBackgroundViewTag 
    insetView.translatesAutoresizingMaskIntoConstraints = false 
    view.addSubview(insetView) 
    view.sendSubview(toBack: insetView) 

    insetView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true 
    insetView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true 
    insetView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true 
    insetView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true 

    insetView.backgroundColor = color 
} 

}

関連する問題