All Projects → bardonadam → Slidingtabbar

bardonadam / Slidingtabbar

Licence: mit
A custom TabBar view with sliding animation written in Swift.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Slidingtabbar

Taniwhatextfield
My first cocoapod framework
Stars: ✭ 26 (-69.05%)
Mutual labels:  cocoapods, ios-ui
Rsformview
A Cocoapods library designed to easily create forms with multiple data entry fields
Stars: ✭ 84 (+0%)
Mutual labels:  cocoapods, ui-components
Tbactionsheet
A Custom&Powerful Action Sheet For iOS. 一个 ActionSheet 满足所有样式!超高自由度的可定制!
Stars: ✭ 942 (+1021.43%)
Mutual labels:  cocoapods, ios-ui
Cariocamenu
The fastest zero-tap iOS menu.
Stars: ✭ 785 (+834.52%)
Mutual labels:  ios-ui, ui-components
Mojilist
🛍 Create shopping lists with emojis!
Stars: ✭ 60 (-28.57%)
Mutual labels:  ios-app, cocoapods
Xlpagertabstrip
Android PagerTabStrip for iOS.
Stars: ✭ 6,671 (+7841.67%)
Mutual labels:  cocoapods, ios-ui
Qmuidemo ios
Sample Code for QMUI iOS
Stars: ✭ 912 (+985.71%)
Mutual labels:  ios-ui, ui-components
Multiprogressview
📊 An animatable view that depicts multiple progresses over time. Modeled after UIProgressView
Stars: ✭ 614 (+630.95%)
Mutual labels:  cocoapods, ui-components
Wstagsfield
An iOS text field that represents tags, hashtags, tokens in general.
Stars: ✭ 1,013 (+1105.95%)
Mutual labels:  cocoapods, ui-components
Cocoaasyncsocket demo
基于AsyncSocket搭建即时通讯体系 . 包含TCP连接 , 消息发送 , 消息接收 , 心跳处理 ,断网重连 , 消息超时 , 消息分发 , 数据库结构设计 , 消息丢失等 . 以及UI设计, 文本表情消息/语音消息/图片消息/视频消息/文件消息/撤回消息/提示语消息的实现思路讲解
Stars: ✭ 981 (+1067.86%)
Mutual labels:  ios-app, ios-ui
Qmui ios
QMUI iOS——致力于提高项目 UI 开发效率的解决方案
Stars: ✭ 6,433 (+7558.33%)
Mutual labels:  ios-ui, ui-components
Drawer Menu Swift
Drawer menu implementation in Swift 4
Stars: ✭ 74 (-11.9%)
Mutual labels:  ios-app, navigation
Koyomi
Simple customizable calendar component in Swift 📆
Stars: ✭ 716 (+752.38%)
Mutual labels:  cocoapods, ui-components
Cascadingtabledelegate
A no-nonsense way to write cleaner UITableViewDelegate and UITableViewDataSource in Swift.
Stars: ✭ 931 (+1008.33%)
Mutual labels:  cocoapods, ios-ui
Swiftoverlays
SwiftOverlays is a Swift GUI library for displaying various popups and notifications
Stars: ✭ 621 (+639.29%)
Mutual labels:  cocoapods, ios-ui
Ppnumberbutton
iOS中一款高度可定制性商品计数按钮(京东/淘宝/饿了么/美团外卖/百度外卖样式)
Stars: ✭ 845 (+905.95%)
Mutual labels:  cocoapods, ios-ui
Iblocalizable
Localize your views directly in Interface Builder with IBLocalizable
Stars: ✭ 463 (+451.19%)
Mutual labels:  cocoapods, ui-components
Iosproject
iOS project of collected some demos for iOS App, use Objective-C
Stars: ✭ 5,357 (+6277.38%)
Mutual labels:  ios-app, ios-ui
Avsqldebugger
A Simple Core Data Debugger that will look inside your apps DB
Stars: ✭ 30 (-64.29%)
Mutual labels:  ios-app, cocoapods
Corenavigation
📱📲 Navigate between view controllers with ease. 💫 🔜 More stable version (written in Swift 5) coming soon.
Stars: ✭ 69 (-17.86%)
Mutual labels:  cocoapods, navigation

SlidingTabBar

CocoaPods Swift 2.2 Twitter Version License

A custom TabBar view with sliding animation written in Swift. Inspired by this dribble.

Also, read how it was done on my blog - part 1, part 2.

Animation

Requirements

  • iOS 8.0+
  • Xcode 7.2+
  • Swift 2+

Installation

SlidingTabBar is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SlidingTabBar"

Usage

First create your UITabBarViewController class and import SlidingTabBar:

import SlidingTabBar

Make it adopt SlidingTabBarDataSource, SlidingTabBarDelegate and UITabBarControllerDelegate protocols:

class YourViewController: UITabBarController, SlidingTabBarDataSource, SlidingTabBarDelegate, UITabBarControllerDelegate

In viewDidLoad() set default UITabBar as hidden, set selectedIndex as you need and set the delegate.

self.tabBar.hidden = true
self.selectedIndex = 1
self.delegate = self

Create class variables:
var tabBarView: SlidingTabBar!
var fromIndex: Int!
var toIndex: Int!

Now initialize tabBarView in viewDidLoad():

// use default UITabBar's frame or whatever you want
// number of selectedTabBarItemColors has to match number of your tab bar items

tabBarView = SlidingTabBar(frame: self.tabBar.frame, initialTabBarItemIndex: self.selectedIndex)
tabBarView.tabBarBackgroundColor = UIColor.black()
tabBarView.tabBarItemTintColor = UIColor.gray()
tabBarView.selectedTabBarItemTintColor = UIColor.white()
tabBarView.selectedTabBarItemColors = [UIColor.red(), UIColor.green(), UIColor.blue()]
tabBarView.slideAnimationDuration = 0.6
tabBarView.datasource = self
tabBarView.delegate = self
tabBarView.setup()

self.view.addSubview(tabBarView)

And implement those delegate and datasource methods:

// MARK: - SlidingTabBarDataSource
    
func tabBarItemsInSlidingTabBar(tabBarView: SlidingTabBar) -> [UITabBarItem] {
    return tabBar.items!
}
    
// MARK: - SlidingTabBarDelegate
    
func didSelectViewController(tabBarView: SlidingTabBar, atIndex index: Int, from: Int) {
    self.fromIndex = from
    self.toIndex = index
    self.selectedIndex = index
}
    
// MARK: - UITabBarControllerDelegate
    
func tabBarController(tabBarController: UITabBarController, animationControllerForTransitionFromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    
    // use same duration as for tabBarView.slideAnimationDuration
    // you can choose direction in which view controllers should be changed:
    // - .Both(default),
    // - .Reverse,
    // - .Left,
    // - .Right 
    return SlidingTabAnimatedTransitioning(transitionDuration: 0.6, direction: .Both,
     fromIndex: self.fromIndex, toIndex: self.toIndex)
}

Finally set things up in the Storyboard:

  1. Add native UITabBarController to the storyboard, establish relationships with its view controllers.
  2. Choose YourViewController as custom class for UITabBarController.
  3. Set images for all tab bar items:

Imgur

If you're implementing 3d touch - Home Screen Quick Actions, add this to AppDelegate:

func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
	
    // whatever type you have
    if shortcutItem.type == UIApplicationShortcutItem.type { 
        let tabBarController = (window?.rootViewController as! YourViewController)
        tabBarController.selectedIndex = 1 // whatever view controller you need
        tabBarController.tabBarView.initialTabBarItemIndex = tabBarController.selectedIndex
        tabBarController.tabBarView.reloadTabBarView()
            
        completionHandler(true)
    }
        
    completionHandler(false)
}

Enjoy! :)

Author

Adam Bardon, [email protected], @bardonadam

License

SlidingTabBar is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].