gpt4 book ai didi

swift - 如何使工具栏附加到底部 iOS Swift

转载 作者:搜寻专家 更新时间:2023-11-01 05:32:56 24 4
gpt4 key购买 nike

我有一个标签栏和导航栏的问题。有一个工具栏我需要显示在标签栏的顶部,但附在最底部。

现在我得到这个:

enter image description here

我的代码是:

  private func showToolBar() {
tabBarController?.tabBar.isHidden = true
navigationController?.setToolbarHidden(false, animated: true)

let archiveButton = UIBarButtonItem(image: #imageLiteral(resourceName: "deactivateIcons"), style: .plain, target: self, action: #selector(archive))
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)
let refreshButton = UIBarButtonItem(image: #imageLiteral(resourceName: "changeStatusIcons"), style: .plain, target: self, action: #selector(refresh))
archiveButton.tintColor = Colors.Purple
refreshButton.tintColor = Colors.Purple

setToolbarItems([archiveButton, flexibleSpace, refreshButton], animated: true)

navigationController?.toolbar.setShadowImage(UIImage(), forToolbarPosition: .bottom)

}

所以工具栏恰好出现在标签栏的顶部。如何解决这个问题?提前致谢!

最佳答案

试试这个:

将该代码放在 showToolBar() 函数的最后一行

让 screenSize: CGRect = UIScreen.main.bounds
navigationController?.toolbar.frame = CGRect(x: 0, y: screenSize.height - tabBarHeight - 50, width: screenSize.width, height: 50)

关于swift - 如何使工具栏附加到底部 iOS Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51561870/

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