HHTabBarView 2.3.0

HHTabBarView 2.3.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2019 年 9 月
SPM支持 SPM

Hemang Shah 维护。



  • 作者:
  • hemangshah

HHTabBarView

轻量级的自定义标签栏视图。

Build Status License Platform Swift 4.x MadeWithLove Awesome-Swift

  1. 屏幕截图
  2. 功能
  3. 安装
  4. 设置
  5. 待办事项
  6. 致谢
  7. 感谢
  8. 许可证

屏幕截图

Only Icon Icon (top) with title (bottom) Only Title
Icon (left) with title (right) Icon (right) with title (left) Icon (bottom) with title (top)
HHTabBarView top position HHTabBarView top position (iPhoneX)
Usage

功能

  1. 易于配置和设置。创建带有标题、图像或两者的标签页。
  2. 动态标签页配置。
  3. 在完成块中检测点击。
  4. 在单个标签页中显示/隐藏徽章值。轻松配置以满足需求。
  5. 锁定/解锁特定标签页。
  6. 轻松显示/隐藏 UINavigationBar 和 HHTabBarView。
  7. 轻量级,无依赖。
  8. 根据需求更改 HHTabBarView 的 UI(从左到右或从右到左)。
  9. 根据 UI 需求更改 HHTabBarView 位置。支持:顶部和底部(默认)。
注意:不建议在顶部显示 HHTabBarView。它始终在底部显示得最好。

安装

  1. 手动 – 将 HHTabBarView/Source 文件夹添加到您的项目中。然后您就可以使用 HHTabBarView 了。

  2. CocoaPods:– pod 'HHTabBarView'

您可以阅读特定版本的 变更日志 文件。

配置

重要:请注意,HHTabBarView 目前不支持 UIStoryBoard。这意味着您必须以编程方式创建 HHTabBarView。建议在 AppDelegate.swift 中配置 HHTabBarView 以便于您使用。

  1. 初始化并保持对 HHTabBarView 的引用。📌
    let hhTabBarView = HHTabBarView.shared
  1. 保持对 iOS 默认 UITabBarController 的引用。📌
    let referenceTabBarController = HHTabBarView.shared.referenceUITabBarController
  1. 配置引用的 UITabBarController📌
    func setupReferenceUITabBarController() -> Void {
        
        //Creating a storyboard reference
        let storyboard = UIStoryboard.init(name: "Main", bundle: Bundle.main)
        
        //Creating navigation controller for navigation inside the first tab.
        let navigationController1: UINavigationController = UINavigationController.init(rootViewController: storyboard.instantiateViewController(withIdentifier: "FirstViewControllerID"))
        
        //Creating navigation controller for navigation inside the second tab.
        let navigationController2: UINavigationController = UINavigationController.init(rootViewController: storyboard.instantiateViewController(withIdentifier: "SecondViewControllerID"))
        
        //Update referenced TabbarController with your viewcontrollers
        referenceTabBarController.setViewControllers([navigationController1, navigationController2], animated: false)
    }
  1. 配置 HHTabBarView📌
    //Update HHTabBarView reference with the tabs requires.
    func setupHHTabBarView() -> Void {
        
        //Default & Selected Background Color
        let defaultTabColor = UIColor.white
        let selectedTabColor = UIColor.init(red: 234/255, green: 218/255, blue: 195/255, alpha: 1.0)
        let tabFont = UIFont.init(name: "Helvetica-Light", size: 14.0)
        
        //Create Custom Tabs
        let t1 = HHTabButton.init(withTitle: "Calendar", tabImage: UIImage.init(named: "Calendar")!, index: 0)
        t1.titleLabel?.font = tabFont
        t1.titleLabel?.textColor = UIColor.black
        t1.setHHTabBackgroundColor(color: defaultTabColor, forState: .normal)
        t1.setHHTabBackgroundColor(color: selectedTabColor, forState: .selected)
        
        let t2 = HHTabButton.init(withTitle: "Refresh", tabImage: UIImage.init(named: "Refresh")!, index: 1)
        t2.titleLabel?.font = tabFont
        t2.titleLabel?.textColor = UIColor.black
        t2.setHHTabBackgroundColor(color: defaultTabColor, forState: .normal)
        t2.setHHTabBackgroundColor(color: selectedTabColor, forState: .selected)
        
        //Note: As HHTabButton are subclassed of UIButton so you can modify it as much as possible.
        
        //Set Custom Tabs
        hhTabBarView.tabBarTabs = [t1, t2]
        
        //Set Default Index for HHTabBarView.
        hhTabBarView.defaultIndex = 1
        
        //Show Animation on Switching Tabs
        hhTabBarView.tabChangeAnimationType = .none
        
        //Handle Tab Change Event
        hhTabBarView.onTabTapped = { (tabIndex) in
            print("Selected Tab Index:\(tabIndex)")
        }
    }
  1. 在配置📌
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        
        //Setup HHTabBarView
        setupReferenceUITabBarController()
        setupHHTabBarView()
        
        //Setup Application Window
        self.window = UIWindow.init(frame: UIScreen.main.bounds)
        self.window?.rootViewController = self.referenceTabBarController
        self.window?.makeKeyAndVisible()
        
        return true
    }
  1. 完成!

待办事项[s]

  • 更新 README,包含多个示例用法和截图。

您可以通过 watch 来查看 HHTabBarView 的持续更新。敬请关注。

您对这个类有什么改进的想法吗?请打开一个 问题    

致谢

Hemang Shah

您可以发送邮件到 此链接 联系。  

谢谢你们!!

请查看 贡献 获取详细信息。

许可协议

MIT 许可协议(MIT)

详细信息请参阅 许可协议 文件。