【问题标题】:How to make a toolbar be attached to bottom iOS Swift如何使工具栏附加到底部 iOS Swift
【发布时间】:2018-07-27 16:17:48
【问题描述】:

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

现在我得到了这个:

我的代码是:

  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)

}

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

【问题讨论】:

  • 这是 iOS 中的一个已知问题。请将其作为错误报告给 Apple。

标签: swift uitabbar uitoolbar


【解决方案1】:

试试这个:

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

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

【讨论】:

    猜你喜欢
    • 2022-11-10
    • 2012-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-27
    • 1970-01-01
    相关资源
    最近更新 更多