Coder Social home page Coder Social logo

sptabbarcontroller's Introduction

SwiftPM compatible Carthage Compatible CocoaPods Swift v5

SPTabBarController is a highly customizable TabBarController component, which is inherited from UITabBarController.

Why?

In real-world development, we may encounter the situation of customizing the UITabBar. For instance: change font style, add animation, and use bigger items. However it's hard to do with UITabBarItem.

With SPTabBarController, You can easily achieve these!

- Feature Description
1 Default style You can get a system-like style by initializing the TabBar with SPTabBarController directly.

UITabBarController style:

System native style

SPTabBarController default style:

ES system-like style
2 Default style with "More" item If the items are more than the maximum number of displays, there will be a "More" item.

UITabBarController with "More":

enter image description here

SPTabBarController with "More":

enter image description here
3 Mix UITabBarItem and SPTabBarItem You can set any item as you want, including UITabBarItem and SPTabBarItem.

SPTabBar and UITabBar mixed style:

enter image description here

SPTabBar and UITabBar mixed style with "More":

enter image description here
4 UIKit attributes SPTabBarController is compatible with UITabBarController, UITabBar and UITabBarItem's most API attributes. You can migrate to SPTabBarController without any modification of the origin code.

Compatible with UITabBarController's selectedIndex:

enter image description here
5 Any nesting with UINavigationController Developing withUITabBarController, there are two common ways to handle layers:

First :

├── UITabBarController

└──── UINavigationController

└────── UIViewController

└──────── SubviewControllers

Second :

├── UINavigationController

└──── UITabBarController

└────── UIViewController

└──────── SubviewControllers

In the first case, need to set hidesBottomBarWhenPushed = true when pushing subViews. The second is not.

In SPTabBarController, add Container views to UITabBar to be compatible with these two ways。
6 Customizable style With SPTabBarController, you can:

1. Customize selected item's color and style:

enter image description here

2. Add selecting animation:

enter image description here

3. Customize item's background color:

enter image description here

4. Add highlight animation:

enter image description here

5. Add animation to prompt users:

enter image description here

6. And much more ...

7 Customizable item's size

Customizable click event
You can easily customize item's size using SPTabBarController.

When the button's frame is larger than TabBar, HitTest makes the outer TabBar area click valid.

In addition, SPTabBarController can customize click event, and through a block to callback super-layer to handle.

With big item in the middle of TabBar:

enter image description here

With a special hint style:

enter image description here

Customize click event:

enter image description here
8 Default notification style You can get a system-like notification style by initializing the TabBar with SPTabBarController directly.

UITabBarController notification style:

enter image description here

SPTabBarController system-like notification style:

enter image description here
9 Customizable notification style With SPTabBarController, you can:

1. Customize notification animation:

enter image description here

enter image description here

2. Customize prompt style:

enter image description here

3. And much more ...

10 Lottie Through customizing ContentView, you are able to add Lottie's LAAnimationView to Item(s)

enter image description here

Requirements

  • Xcode 8 or later
  • iOS 8.0 or later
  • ARC
  • Swift 5 or later

Demo

You can download and build SPTabBarControllerExample project, and you will find more examples to use SPTabBarController, and also more examples to customize UITabBar。

Usage

Swift Package Manager

...
dependencies: [
    .package(name: "SPTabBarController", url: "https://github.com/tyronesong/SPTabBarController.git", from: "2.9.0-spm")
]
...

TODO

  1. The Containers' layout is purely based on code,using Autolayout will be better.
  2. When there is "More," if edited, problems occur.
  3. Partial UITabBarItem attributes are not bridge to SPTabBarItem.
  4. The picture of 'More' item in SPTabBarItemMoreContentView is not set into framework, plan to convert it to CGBitmap.

sptabbarcontroller's People

Contributors

tyronesong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.