TabBarController adding custom button not clickable issue [duplicate]

纵然是瞬间 提交于 2020-02-01 06:55:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!