- Notifications
You must be signed in to change notification settings - Fork1
📱 TabBar – highly customizable tab bar (i.e. TabView) for your SwiftUI application.
License
winddpan/TabBar
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
SwiftUI
standardTabView
component is not so flexible and to customize it you have to modify appearance proxy ofUITabBar
or implement your own one from scratch. The goal of this library is to solve this problem.
- SwiftUI
- iOS 13.0 or above
TabBar is available throughSwift Package Manager
In Xcode select:
File > Swift Packages > Add Package Dependency...
Then paste this URL:
https://github.com/onl1ner/TabBar.git
To start usingTabBar
you have to create an enum which will implementTabbable
protocol:
enumItem:Int,Tabbable{case first=0case secondcase thirdvaricon:String{switchself{case.first: // Name of icon of first item. case.second: // Name of icon of second item.case.third: // Name of icon of third item.}}vartitle:String{switchself{case.first: // Title of first item. case.second: // Title of second item.case.third: // Title of third item.}}}
After that you will be able to createTabBar
instance:
structContentView:View{@Stateprivatevarselection:Item=.first@Stateprivatevarvisibility:TabBarVisibility=.visiblevarbody:someView{TabBar(selection: $selection, visibility: $visibility){Text("First").tabItem(for:Item.first)Text("Second").tabItem(for:Item.second)Text("Third").tabItem(for:Item.third)}.tabBar(style:CustomTabBarStyle()).tabItem(style:CustomTabItemStyle())}}
After these actions tab bar with default style will be created.
TabBar
component is highly customizable. This is achieved by introducingTabBarStyle
andTabItemStyle
protocols. By implementing each of the protocol you will be able to build your custom tab bar.NOTE thatTabBar
automaticaly pushes down to bottom any of tab bar styles.
After creating your custom styles you may inject them to your tab bar by usingtabBar(style:)
andtabItem(style:)
functions. Here is the showcase of default style and one of the examples of what you can achieve by customizing tab bar:
If you struggle with something feel free toopen an issue. Pull requests are also appreciated.
TabBar is under the terms and conditions of the MIT license.
MIT LicenseCopyright (c) 2021 Tamerlan SatualdypovPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.