Giter Site home page Giter Site logo

sotabbar's Introduction

SOTabBar

CocoaPods Platforms





๐Ÿ“‹ Requirements

SOTabBar requires iOS 9.3 or above, and is compatibile with Swift 4/5.

๐Ÿ“ฒ Installation

CocoaPods

SOTabBar is available through CocoaPods:

pod 'SOTabBar'

Carthage

SOTabBar is also available through Carthage:

github "Ahmadalsofi/SOTabBar"

๐Ÿš€ Usage

The Basics

  1. Set up your view controller with the an array of view controllers that you want to appear.
  2. Make your main View Controller subclass from SOTabBarViewController.
  3. return the array of your ViewControllers:
import UIKit
import SOTabBar
class MainViewController: SOTabBarViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let firstVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "First_ID")
        let secondVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Second_ID")
       
        firstVC.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "firstImage"), selectedImage: UIImage(named: "firstSelectedImage"))
        secondVC.tabBarItem = UITabBarItem(title: "Chat", image: UIImage(named: "secondImage"), selectedImage: UIImage(named: "secondSelectedImage"))
	
        viewControllers = [firstVC, secondVC]
    }
}
  1. you can trigger your tab bar action by override the following function in your MainViewController
 override func soTabBar(_ tabBar: SOTabBarView, didSelectTabAt index: Int) {
      print("did Tapped On \(index)")
  }

๐ŸŽจ Customization

You should set your customization before return the array of the viewcontrollers

class MainViewController: SOTabBarViewController {

    override func loadView() {
        super.loadView()
	    // SOTabBarSetting.propertyToCustomize = value
    }
}

tabBarHeight

    SOTabBarSetting.tabBarHeight = 100.0

tabBarTintColor

    SOTabBarSetting.tabBarTintColor = UIColor.red

tabBarBackground

    SOTabBarSetting.tabBarBackground = UIColor.purple

tabBarCircleSize

    SOTabBarSetting.tabBarCircleSize = CGSize(width: 50.0, height: 50.0)
  	 // or 
    SOTabBarSetting.tabBarCircleSize = CGSize(width: 80.0, height: 80.0)

tabBarSizeImage

    SOTabBarSetting.tabBarSizeImage = CGSize(width: 40.0, height: 40.0)

tabBarShadowColor

    SOTabBarSetting.tabBarShadowColor = UIColor.red.cgcolor

tabBarSizeSelectedImage

    SOTabBarSetting.tabBarSizeSelectedImage = CGSize(width: 40.0, height: 40.0)

tabBarAnimationDurationTime

    SOTabBarSetting.tabBarAnimationDurationTime = 2

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Author

โค๏ธ Contributing

Bug reports and pull requests are welcome on GitHub

๐Ÿ‘ฎ๐Ÿปโ€โ™‚๏ธ License

The library is available as open source under the terms of the MIT License.

sotabbar's People

Contributors

ahmadalsofi avatar asafbaibekov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sotabbar's Issues

Selected Tab Title is not displaying on first launch or when launched app from killed state

Thank you so much for this amazing library.

There are two issues I was unable to figure out solution to:

  1. Selected tab title is not visible (though it is view hierarchy).
  2. How to show title for all the tab bar items despite selected state.
  3. How should I select 2nd Tab on first launch or when launched from killed state.

Added image for the reference of issue #1
Thank you so much!

IMG_1F3D60E55D2C-1

Errors in readme

For example SOTabBarViewController doesn't exist. Maybe SOTabBarController?

How to hide tabBar other screens

how to hide tabBar in SOTabBar, need to hide other inside screens ex: in UITabBarController we used , tabBarController?.tabBar.isHidden = true

Can't change elements after creation

For example I need to show "login view controller" and if user input login and password then I need to show "profile view controller. How to do that with this control?
I try to overwrite viewControllers property but it seems your control appends changes instead of replacing
And of course tabBar property is made private which doesn't allow to fix this bug externally. Even if I find it as a subview - each its method is marked private!

Men if you develop a public library for using with cocoapods use private in exception cases only!

RTL Does not support

Hi,
Its a great experience after adding your library into my project. but i need to give support for RTL language now. but seems i stuck there.
can you please also provide support for RTL language as well ?
Thank you in Advance

Can't find SOTabBarView in scope???

import UIKit
import SOTabBar
public var home = true
class ViewController: SOTabBarController {

override func loadView() {
    super.loadView()
    SOTabBarSetting.tabBarTintColor = .clear
    SOTabBarSetting.tabBarCircleSize = CGSize(width: 40, height: 40)
    SOTabBarSetting.tabBarHeight = 50
    SOTabBarSetting.tabBarAnimationDurationTime = 0.25
    SOTabBarSetting.tabBarSizeSelectedImage = 30
    SOTabBarSetting.tabBarSizeImage = 30
}

override func viewDidLoad() {
    super.viewDidLoad()
    
    self.delegate = self
    let homeStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "HOME_ID")
    let chatStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CHAT_ID")
    let sleepStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SLEEP_ID")
    let musicStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MUSIC_ID")
    let meStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ME_ID")
    homeStoryboard.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "Home"), selectedImage: UIImage(named: "HomeFilled"))
    chatStoryboard.tabBarItem = UITabBarItem(title: "Search", image: UIImage(named: "Search"), selectedImage: UIImage(named: "SearchFilled"))
    sleepStoryboard.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "abc"), selectedImage: UIImage(named: "abcn"))
    musicStoryboard.tabBarItem = UITabBarItem(title: "Inbox", image: UIImage(named: "Inbox"), selectedImage: UIImage(named: "InboxFilled"))
    meStoryboard.tabBarItem = UITabBarItem(title: "Profile", image: UIImage(named: "Profile"), selectedImage: UIImage(named: "ProfileFilled"))

    viewControllers = [homeStoryboard, chatStoryboard,sleepStoryboard,musicStoryboard,meStoryboard]
}
override func soTabBar(_ tabBar: SOTabBarView, didSelectTabAt index: Int) {
         print("did Tapped On \(index)")
     }

}

extension ViewController: SOTabBarControllerDelegate {
func tabBarController(_ tabBarController: SOTabBarController, didSelect viewController: UIViewController) {
let title = viewController.tabBarItem.title
print(title ?? "")

}

}

Getting error in SOTabBarItem class

Fatal error: You should set image to all view controllers: file /Pods/SOTabBar/SOTabBar/Classes/SOTabBarItem.swift, line 35
2020-03-13 Fatal error: You should set image to all view controllers: file /Pods/SOTabBar/SOTabBar/Classes/SOTabBarItem.swift, line 35

Unable to set selectedIndex

i am trying to set initial index to '2' but it's not working.
I even tried to change the selectedIndex in the library but its not working.

func setUpTabBarController(){

        self.delegate = self
        self.selectedIndex = 2

        let homeStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "HomeViewController")
        let searchStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SearchViewController")
        let recordStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "RecordViewController")
        let notificationStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "NotificationViewController")
        let profileStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "UserProfileViewController")
        
        homeStoryboard.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_Selected"))
        searchStoryboard.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "search"), selectedImage: UIImage(named: "search-selected"))
        recordStoryboard.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "record"), selectedImage: UIImage(named: "record"))
        notificationStoryboard.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "notification"), selectedImage: UIImage(named: "notification-selected"))
        profileStoryboard.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "profile"), selectedImage: UIImage(named: "profile-selected"))
           
        viewControllers = [homeStoryboard, searchStoryboard,recordStoryboard,notificationStoryboard,profileStoryboard]
}

i also tried to set the index in the podfile but it's not working for me.

open class SOTabBarController: UIViewController, SOTabBarDelegate {

weak open var delegate: SOTabBarControllerDelegate?

public var selectedIndex: Int = 2
public var previousSelectedIndex = 0

public var viewControllers = [UIViewController]() {
    didSet {
        tabBar.viewControllers = viewControllers
    }
} 

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.