如何在 UITabBar 中显示六个 TabBarItem

How to show six TabBarItem in UITabBar

我可以在UITabBar 中显示六个TabBarItem,我尝试调整TabBarItem 的大小但它不能。 uitabbar

默认情况下 UITabBarController 你不能,因为它会添加 More 选项卡,如下所示:

您需要单击 More 选项卡以显示其他选项。

但是您可以使用像 AZTabBarController 这样的第三方库,它将填充所有六个选项,如下所示:

可以找到更多用于选项卡栏的库 HERE

这与 "Human Interface Guidelines" 相悖,但使用不带 tabBarController 的 tabBar 可以拥有任意数量的 TabBarItem。您可以在情节提要中布置 tabBar 和项目。响应点击符合 UITabBarDelegate 并至少实现 didSelectItem

import UIKit

class AdminViewController: UIViewController, UITabBarDelegate {
@IBOutlet weak var tabbar: UITabBar!
override func viewDidLoad() {
    super.viewDidLoad()
    tabbar.delegate = self;
}

func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) {
    print(item.tag);
    switch item.tag { // switching by tag is not required, just an option
    case 1:
     // segue or push or present something
    case 2: 
     // segue or push or present something
    default:
    break
    }    
}