问题
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)
}
}
I don't want to add it as view.addSubView
because the view doesn't disappear when I call hidesBottomBarWhenPushed
回答1:
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)
}
}
来源:https://stackoverflow.com/questions/45881696/tabbarcontroller-adding-custom-button-not-clickable-issue