SSCustomTabbar 2.0.7

SSCustomTabbar 2.0.7

Sumit goswami[Simform]Simform Solutions维护。



  • Sumit Goswami

SSCustomTabbar

具有原生控制的简单动画标签栏。

Version License Platform Swift Version PRs Welcome

Example

Example

需求

  • iOS 11.0+
  • Xcode 10.0+

安装

SSCustomTabbar不包含任何外部依赖。

它可以通过CocoaPods获取。要安装,只需将以下行添加到您的Podfile中

pod 'SSCustomTabbar'

UIKit 使用示例

将UITabbarController设置为SSCustomTabBarViewController

alt text

将UITabBar设置为SSCustomTabBar

alt text

将UITabBar设置为SSCustomTabBar反向曲线

alt text

SwiftUI 使用示例

struct TabItem: View {

  var text: String
  @State var isNextActive: Bool = false
  @Binding var isTabBarHidden: Bool

  var body: some View {
     NavigationView {
           ZStack {
              NavigationLink(destination: PushedView(isTabBarHidden: self.$isTabBarHidden, showPushedView: self.$isNextActive), isActive: self.$isNextActive) {
                   EmptyView()
              }
            
              VStack(spacing: 30) {
                
                   Button(action: {
                       self.isNextActive = true
                   }) {
                       Text("Tap to Push")
                   }
               }
           }.onAppear {
               self.isTabBarHidden = false
           }
       }
  }

}


struct ContentView: View {

   @State var isTabBarHidden: Bool = false

   var body: some View {
       tabView
        .onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
            SwiftUITabBarController.refreshViews()
       }
   }

   var tabView: some View {
       let vc1 = SwiftUITabView(content: UIHostingController(rootView: TabItem(text: "Home", isTabBarHidden: self.$isTabBarHidden)), title: "Home", selectedImage: "iconHomeSelected", unSelectedImage: "iconHome")
       let vc2 = SwiftUITabView(content: UIHostingController(rootView: TabItem(text: "Favorite", isTabBarHidden: self.$isTabBarHidden)), title: "Favorite", selectedImage: "iconFavoriteSelected", unSelectedImage: "iconFavorite")
       let vc3 = SwiftUITabView(content: UIHostingController(rootView: TabItem(text: "Video", isTabBarHidden: self.$isTabBarHidden)), title: "Video", selectedImage: "iconVideoSelected", unSelectedImage: "iconVideo")
       let vc4 = SwiftUITabView(content: UIHostingController(rootView: TabItem(text: "Profile", isTabBarHidden: self.$isTabBarHidden)), title: "Profile", selectedImage: "iconProfileSelected", unSelectedImage: "iconProfile")
       let vc5 = SwiftUITabView(content: UIHostingController(rootView: TabItem(text: "Chat", isTabBarHidden: self.$isTabBarHidden)), title: "Chat", selectedImage: "iconChatSelected", unSelectedImage: "iconChat")
    
       let tabBarView = SwiftUITabBarController(tabItems: [vc1, vc2, vc3, vc4, vc5], configuration: .constant(SSTabConfiguration()), isTabBarHidden: self.$isTabBarHidden)
       return tabBarView
  }

}

自定义

您可以更改

  • 栏高
  • 未选中项的色彩色调
  • 波浪高度
  • 动画点(位置)
  • 层的背景颜色

alt text

alt text

alt text

添加徽章值

alt text

添加/更新徽章值

let tabBarController = self.tabBarController as? SSCustomTabBarViewController
tabBarController?.addOrUpdateBadgeValueAtIndex(index: 0, value: "Your Value Here")

删除徽章值

let tabBarController = self.tabBarController as? SSCustomTabBarViewController
tabBarController?.removeBadgeValueAtIndex(index: 1)

删除所有徽章值

let tabBarController = self.tabBarController as? SSCustomTabBarViewController
tabBarController?.removeAllBadges()

贡献

我们非常欢迎您对SSCustomTabMenu的贡献,更详细的信息请查看LICENSE文件。

Android库。

  • 您也可以在我们的GitHub库中查看Android库。

许可

SSCustomTabbar遵循MIT许可,更多详细信息请见LICENSE文件。