0

I have a question about safe area.
And I write a code and build in two simulators of iOS version 10.2 and 11.4.
It shows different part of red rectangle area like following image.
What's wrong with me?
Thanks.

image

code here:

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        window = UIWindow(frame: UIScreen.main.bounds)
        window?.rootViewController = UINavigationController(rootViewController: ViewController())
        window?.makeKeyAndVisible()

        return true
    }
}

class ViewController: UIViewController {

    let tableView = UITableView()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "TITLE HERE"

        tableView.dataSource = self
        tableView.delegate = self

        self.view.addSubview(tableView)
        tableView.snp.makeConstraints { (make) in
            make.left.equalTo(10)
            make.top.equalTo(self.topLayoutGuide.snp.bottom)
            make.right.bottom.equalTo(-10)
        }

    }

}

extension ViewController: UITableViewDelegate, UITableViewDataSource {

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 20
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = UITableViewCell()
        cell.textLabel?.text = "\(indexPath) TEST"

        return cell
    }

}
JimmyLee
  • 507
  • 2
  • 7
  • 24

0 Answers0