uias / Tabman

™️ A powerful paging view controller with interactive indicator bars
https://uias.github.io/Tabman
MIT License
2.87k stars 238 forks source link

When adding bar to a custom view, tabbar covers all view, no room left for view controllers. #372

Closed yigitserin closed 5 years ago

yigitserin commented 5 years ago

I have some views in my view controller and I wanted to add tabs below these views. So I added a empty UIView to add tabs to it. However, tabs are taking whole screen now, and there is no room for view controllers. How to solve this?

This is how it looks

This is my current code:

        self.dataSource = self
        //self.isScrollEnabled = false
        // Create bar
        let bar = TMBar.ButtonBar()

        bar.layout.interButtonSpacing = 24.0
        bar.indicator.weight = .light
        bar.layout.contentMode = .fit

        bar.buttons.customize { (button) in
            button.font = UIFont.systemFont(ofSize: 14, weight: .semibold)
        }

        addBar(bar, dataSource: self, at: .custom(view: tabsArea, layout: nil))
msaps commented 5 years ago

@yigitserin how is your view tabsArea constrained?

When adding a bar to a custom view without a layout closure, it is simply constrained to the leadingAnchor,topAnchor,trailingAnchorandbottomAnchorof that view. By default this will intrinsically size this custom view to the required size of the bar. It appears that yourtabsArea` view is constrained to the bottom of the superview?

yigitserin commented 5 years ago

Yes it is constrained to the bottom of the superview. What is the correct way to setup the layout closure?

msaps commented 5 years ago

@yigitserin you don't need it constrained to the bottom of the superview, it will intrinsically size with the bar 🙂