TabBarController 添加自定义按钮不可点击问题 [英] TabBarController adding custom button not clickable issue
本文介绍了TabBarController 添加自定义按钮不可点击问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 tabBarController 上添加了一个自定义按钮,该按钮位于 tabBarController 上,当我在 tabBarController 中点击它时它被点击> 它工作正常,但如果我点击标签栏之外的部分,它就无法点击.
I'm adding a custom button over the tabBarController and the button becomes over the tabBarController it is clicked when I hit it inside the tabBarController it is working fine but if I hit the part outside the tabar it is not clickable.
class CustomBar: UITabBarController, UITabBarControllerDelegate {
func addButton() {
mainBasketView.frame = CGRect(x: self.view.frame.size.width / 2 - 30, y: -20, width: 58, height: 58)
mainBasketView.basketButton.addTarget(self, action: #selector(self.btnNewMoment_Action), for: UIControlEvents.touchUpInside)
tabBar.addSubview(mainBasketView)
}
}
我不想将它添加为 view.addSubView
因为当我调用 hidesBottomBarWhenPushed
I don't want to add it as view.addSubView
because the view doesn't disappear when I call hidesBottomBarWhenPushed
推荐答案
你应该增加你的 Tabar 高度默认为 49,你的按钮是 58
you should increase your tabar height its 49 default and your button is 58
extension UITabBar {
override open func sizeThatFits(_ size: CGSize) -> CGSize {
return CGSize(width: UIScreen.main.bounds.width, height: 60)
}
}
这篇关于TabBarController 添加自定义按钮不可点击问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文