Giter Site home page Giter Site logo

dhaval1094 / dtscrollabletabbar-swift Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 3.0 3.45 MB

It is simple, light weight and easily manageable scrollable tab bar. It can be used as fixed top bar as well. It will work on both landscape and portrait mode. -> Swift 5.0.

Swift 100.00%
ios swift scrollable tabbar scrollview topbar

dtscrollabletabbar-swift's Introduction

DTScrollableTabbar-Swift

Screenshot

It is simple, light weight and easily manageable scrollable tab bar. It can be used as fixed top bar as well. For using it you have to pass just array of titles and type of tabbar design. It will work on both landscape and portrait mode. -> Swift 5.0.

The tabbar design is set for mainly these three attributes. You can choose one attribute from them.

  • First - dynamic size scrollable tabbar. In this all items(buttons) in the tabbar will be set with the intrinsic label size of the button and given pading value. Pading is for spacing on the left and right side of the title of the button.
  • Second - max title width size tabbar. In this all items(buttons) in the tabbar will be set as per the maximum button titles size and given pading value.
  • Third - Fixed tabbar frame size. In this the size of the tabbar view will be fix with the given constraints. So the tabbar will not be scrollable because the view will be fixed.

App Functionality

Layer structure

Layer structure

Attributes

For managing the design just pass the attributes. The attributes are as follows..

var arrButtonTitles = [String]()                 // Pass array of button titles
var btnColor: UIColor?                           // Button's background color
var stripColor: UIColor?                         // Strip background color
var btnTextColor: UIColor?                       // Button's text color
var stripHeight: CGFloat = 0.0                   // Strip's height
var btnFont = UIFont()                           // Font type for the button
var setPading: CGFloat = 0.0                     // Pading (Left-Right insets) for the button title
var setBoarderWidth: CGFloat = 0.0               // Border width for the button
var setBoarderColor: UIColor?                    // Border color for the button
var setByMaxButtonTitle = false                  // Set fix width for the button
var fitToTheScreenWidth = false                  // Set scrollview content fit to the screen size and devide equally

Usage

It could be used in project as follows.

//Take a UIView object in story board. Set subclass DTTabBarView to it.
//Then take outlet.
 @IBOutlet var tabBarView: DTTabBarView!
 
 //Assign delegate 
 tabBarView.delegate = self
 
 //Take object of attributes for the content of the tabbar
 let objAttributes = DTButtonViewAttributes()
 
 //Set attributes
    objAttributes.arrButtonTitles = ["Apple", "Banana", "Graps", "Watermelon"]
    objAttributes.btnColor = UIColor.darkGray
    objAttributes.btnFont = UIFont(name: "Arial Rounded MT Bold", size: 15) ?? UIFont.systemFont(ofSize: 15)
    objAttributes.stripColor = UIColor(white: 0.8, alpha: 1.0)
    objAttributes.btnTextColor = UIColor.white
    objAttributes.setBoarderColor = UIColor.black
    objAttributes.setBoarderWidth = 0.3
    objAttributes.setPading = 15
    objAttributes.fitToTheScreenWidth = false
    objAttributes.setByMaxButtonTitle = false
    objAttributes.stripHeight = 5
    
  //Assign attributes object to the tabbar view
  tabbarView.objAttributes = objAttributes

You can change any attributes or add items at the run time bu the following code.

    tabbarView.objAttributes?.arrButtonTitles.append("Title")
    tabbarView.refrashTabbar()

DTTabBarViewDelegate is used for getting the button action event in the view controller.

    protocol DTTabBarViewDelegate {
       func tabbarButtonClicked(button: UIButton)
    }

In the view controller..

    func tabbarButtonClicked(button: UIButton) {
         print(button.titleLabel?.text ?? "")
    }

dtscrollabletabbar-swift's People

Contributors

dhaval1094 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.