0

I have a "classic app" with 3 ViewController and a tabBar that I use to change ViewController.

On my first ViewController, I have a button that display a UIView on all the screen, so I hide tabBar with this setTabBarVisible func :

extension UIViewController
{

func setTabBarVisible(visible: Bool, animated: Bool)
{
    //* This cannot be called before viewDidLayoutSubviews(), because the frame is not set before this time

    // bail if the current state matches the desired state
    if (isTabBarVisible == visible) { return }

    // get a frame calculation ready
    let frame = self.tabBarController?.tabBar.frame
    let height = frame?.size.height
    let offsetY = (visible ? -height! : height)

    // zero duration means no animation
    let duration: TimeInterval = (animated ? 0.3 : 0.0)

    //  animate the tabBar
    if frame != nil
    {
        UIView.animate(withDuration: duration)
        {
            self.tabBarController?.tabBar.frame = frame!.offsetBy(dx: 0, dy: offsetY!)
            return
        }
    }
}

var isTabBarVisible: Bool
{
    return (self.tabBarController?.tabBar.frame.origin.y ?? 0) < self.view.frame.maxY
}
}

That's working, the tabBar is hidden and I see all my UIVIew. The problem is, I have a UILabel at bottom of the UIView (at the place I usually display the tabBar), and I can't use my TapGesture on my UILabel, nothing is happening. (if I display the label somewhere else the UITapGesture works good.)

I tried to set zPosition of my tabBar to 0 and zPosition of my UIView to 1 but that's doesn't work either.

How can I get my label clickable at bottom of my view?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Quentin Rth
  • 178
  • 1
  • 15
  • Make sure your label is in the bounds of your view. Try setting the clipsToBounds property of your view to true. If the label is clipped then it means it is out of the views bounds so touch wont be delivered to it. – HAK May 24 '18 at 10:58
  • I tried with "self.clipsToBounds = true" in my UIView's viewDidLoad() and i can still see my UILabel so i guess that's not the problem. Thanks anyway – Quentin Rth May 24 '18 at 11:02
  • I found out the solution. That was related to bounds of my view, I was adding the view to an other view and that other view was not enough height to take all my new view. – Quentin Rth May 24 '18 at 11:45

2 Answers2

0

make sure is true

label.isUserInteractionEnabled = true

Please refer this link may it help you.

  • Yes that's already at true, as I said if my label is somewhere else than at bottom (where the tabBar usually is) i can click on my label and all is working good. But thanks – Quentin Rth May 24 '18 at 11:05
0

Check UILabel.isUserInterration = enable

Make sure that when you hide tabbar, perticular view controller Under bottom bar property is unselect . See atteh imnage.

You can try with programatically also like

ViewController.edgesForExtendedLayout = UIRectEdge.top