简体   繁体   中英

How to create a custom tabbar in swift?

Guys I searched the internet and stackoverflow a lot, but did not find any solution for this.

I want to create a tabbar like this:

我想要的标签栏

I just don't know how to create something like this. Could you please help me. I am just stuck with it for so long, i do not know how to do it.

 let numberOfItems = CGFloat(tabBar.items!.count)
    let tabBarItemSize = CGSize(width: tabBar.frame.width / numberOfItems, height: tabBar.frame.height)
    tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.appBlue(), size: tabBarItemSize).resizableImage(withCapInsets: UIEdgeInsets.zero)


    tabBar.frame.size.width = self.view.frame.width + 4
    tabBar.frame.origin.x = -2

This code does not work for me:

我已经实现的标签栏

If you are looking for a fast solution than I'd recommend you to use library like this . But if you want fully flexible and controlled solution. Then, make it by your own through ViewController which will act as container for you tabBarView and content view controller. So, you get ContainerViewController with two childs: Currently selected ViewController and TabBarController (you own implementation of TabBarView). Whatever you will use both approaches will take time to understand how to use / implement it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM