我在ViewController上面添加tabBar这样的
cardViewController = storyboard?.instantiateViewController(withIdentifier: "CardViewController") as? CardViewController
addChildViewController(cardViewController)
cardViewController.didMove(toParentViewController: self)
view.addSubview(cardViewController.view)
cardViewController.view.frame = CGRect(x: 0, y: view.frame.height - cardHandlAreaHight - tabBarHight,
width: view.bounds.width, height: cardHight)
cardViewController.view.clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)
我得到的 tabBar 的大小是这样的:
tabBarHight = tabBarController?.tabBar.frame.size.height
Run Code Online (Sandbox Code Playgroud)
这适用于所有 iPhone 但不适用于 iPhone X 如何解决这个问题?
在我的情况下,获得这一点的正确方法不是获得 safeArea,而是像这样获得 tabBarFrame 的点
let topTapbarPosition = tabBarController?.tabBar.frame.minY
Run Code Online (Sandbox Code Playgroud)
之后像这样使用它
cardViewController.view.frame = CGRect(x: 0, y: topTapbarPosion! - cardHeight!,
width: view.bounds.width, height: cardHeight!)
Run Code Online (Sandbox Code Playgroud)
它适用于所有型号的 iPhone
| 归档时间: |
|
| 查看次数: |
4524 次 |
| 最近记录: |