4

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.

enter image description here

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

CAN
  • 1,677
  • 4
  • 19
  • 28

1 Answers1

0

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)
        }
    }
Abdelahad Darwish
  • 5,969
  • 1
  • 17
  • 35
  • Thanks for your response but I want to keep that design which looks outside the tabbar. Isn't possible? – CAN Aug 25 '17 at 12:50
  • so check this https://stackoverflow.com/questions/36014073/make-custom-button-on-tab-bar-rounded – Abdelahad Darwish Aug 25 '17 at 12:52
  • In this answer I found that people complaining about hidesBottomBarWhenPushed which doesn't remove the button in the centre. I made a test project which shows the same issue. – CAN Aug 25 '17 at 13:46