TabBar高度太大
请有人解释一下,为什么当我以编程方式创建它时会有这么大的 TabBar?
viewControllers = [
createNavController(for: AssetViewController(), title: NSLocalizedString("Search", comment: ""), image: UIImage(systemName: "magnifyingglass")!),
createNavController(for: AssetViewController(), title: NSLocalizedString("Home", comment: ""), image: UIImage(systemName: "house")!),
createNavController(for: AssetViewController(), title: NSLocalizedString("Profile", comment: ""), image: UIImage(systemName: "person")!)
]
func createNavController(for viewController: UIViewController, title: String, image: UIImage) -> UIViewController {
viewController.tabBarItem.title = "Wallet"
viewController.tabBarItem.image = image
return viewController
}
can please someone explain, why do I have such a huge TabBar when I create it programmatically?
viewControllers = [
createNavController(for: AssetViewController(), title: NSLocalizedString("Search", comment: ""), image: UIImage(systemName: "magnifyingglass")!),
createNavController(for: AssetViewController(), title: NSLocalizedString("Home", comment: ""), image: UIImage(systemName: "house")!),
createNavController(for: AssetViewController(), title: NSLocalizedString("Profile", comment: ""), image: UIImage(systemName: "person")!)
]
func createNavController(for viewController: UIViewController, title: String, image: UIImage) -> UIViewController {
viewController.tabBarItem.title = "Wallet"
viewController.tabBarItem.image = image
return viewController
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您的导航视图控制器框架(高度约束)
并
检查您的 tabar 约束
例子:
self.tabBar.frame = CGRect(x:frame.origin.x, y: UIScreen.main.bounds.size.height - 80, 宽度: UIScreen.main.bounds.size.width, 高度: 80)
check your Navigation view controller frame (height constraint)
and
check your tabar constraint
example:
self.tabBar.frame = CGRect(x: frame.origin.x, y: UIScreen.main.bounds.size.height - 80, width: UIScreen.main.bounds.size.width, height: 80)