I am looking to implement a custom Tab Bar in iOS where selected item is bigger size than the rest of the tabs and peeks out over the content similar to this screenshot.
Could someone point to a tutorial of how to accomplish this preferably in Swift?
To add a tab, first drag a new View Controller object to the storybard. Next control-drag from the tab bar controller to new view controller and select view controllers under Relationship Segue . Your tab bar controller will update with a new tab.
I faced with this task several times. I found a lot of tutorials but I've never found one that gives the ability to create a center button that part of it is out of the tab bar.
At the end, I created an approach to have it done correctly. I implemented a simple example project with instructions how to do that. Please check my Custom Tabbar Center Button repo as an example.
One more benefit of it it's center button hides correctly with the tab bar when you use Hide Button Bar on Push
property.
A UITabBar contains an array of UITabBarItems, which inherit from UIBarItem. But unlike UIBarButtonItem that also inherits from UIBarItem, there is no API to create a UITabBarItem with a customView.
So instead of trying to create a custom UITabBarItem, we’ll just create a regular one and then put the custom UIButton on top of the UITabBar
Not swift, but should be easily translated.
https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar
This one is Swift: https://github.com/itsKaynine/SwiftRaisedTab
Source code for a similar question, using Swift 3: https://stackoverflow.com/a/36016377/300897
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With