I want to put BlueView under NavigationBar on TableViewController. But it does not work.
like [1]: https://i.stack.imgur.com/40Crj.jpg
class TableViewController: UITableViewController {
private func setupView() {
view.addSubview(blueView)
blueView.translatesAutoresizingMaskIntoConstraints = false
blueView.snp.makeConstraints { (make) in
make.left.equalTo(view.snp.left)
make.right.equalTo(view.snp.right)
make.top.equalTo(view.safeAreaLayoutGuide.snp.topMargin)
make.height.equalTo(50)
}
}
}
I found that it works by using viewController with tableview.
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
private func setupView() {
view.addSubview(blueView)
blueView.translatesAutoresizingMaskIntoConstraints = false
blueView.snp.makeConstraints { (make) in
make.left.equalTo(view.snp.left)
make.right.equalTo(view.snp.right)
make.top.equalTo(view.safeAreaLayoutGuide.snp.topMargin)
make.height.equalTo(50)
}
}
}
But I really want to know why? Or anything else ideas about safeAreaLayoutGuide on UITableViewController.