gpt4 book ai didi

ios - Cosmic Mind - 实现 TabsController 时如何调整 View 大小

转载 作者:行者123 更新时间:2023-11-30 11:32:04 28 4
gpt4 key购买 nike

我在向该屏幕插入标题时遇到问题。我怎样才能调整这个 View 的大小?

这是我实现 TabsController 的代码:

    class DashboardViewController: TabsController {

let screenSize = UIScreen.main.bounds

override func viewDidLoad() {
super.viewDidLoad()
}

override func prepare() {
super.prepare()

tabBar.lineColor = UIColor.CustomColor.blue
tabBar.setTabItemsColor(UIColor.CustomColor.grey, for: .normal)
tabBar.setTabItemsColor(UIColor.CustomColor.blue, for: .selected)

tabBarAlignment = .top
tabBar.tabBarStyle = .auto
tabBar.dividerColor = nil
tabBar.lineHeight = 2.0
tabBar.lineAlignment = .bottom
tabBar.backgroundColor = .white
}

}

这是我的选项一代码(选项二代码相同):

    class TeamProjectViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()
prepareTabItem()
setupTableView()
}

fileprivate func setupTableView() {
tableView.backgroundColor = .white
tableView.allowsSelection = false
tableView.separatorColor = UIColor.CustomColor.lightGrey
tableView.register(UINib(nibName: "ProjectTableViewCell", bundle: nil), forCellReuseIdentifier: "cell")
}

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

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ProjectTableViewCell
return cell
}

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 150
}

}

extension TeamProjectViewController {
fileprivate func prepareTabItem() {
tabItem.title = "Option 1"
}
}

这是我的选项卡发生的情况:

The options are way too the top of the screen:

谢谢!

最佳答案

在您的代码中,您没有任何地方可以实际在 TabsController 上设置 View ,其中标题可能存在。您需要包装 TabsController 才能完成此任务。一种方法是使用 ToolbarController:

let toolbarController = ToolbarController(rootViewController: myTabsController)
toolbarController.toolbar.title = "my title"

这是解决您的问题的一种方法。

关于ios - Cosmic Mind - 实现 TabsController 时如何调整 View 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50158241/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com