Sha256: 9d57cd180219eba8752c873218cb9e812b0dafe4d4545f2b2f941fd399e06061

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module MotionTab
  class TabBar
    class << self
      def createTabBarControllerFromData(data)
        mt_tab_controllers = []

        data.each do |tab|
          tab[:badgeNumber] = 0 unless tab[:badgeNumber]
          tab[:tag] = 0 unless tab[:tag]
          
          viewController = tab[:viewController].alloc.init
          viewController.tabBarItem = tabBarIcon(tab[:systemIcon], tab[:tag]) if tab[:systemIcon]
          viewController.tabBarItem.badgeValue = tab[:badgeNumber].to_s unless tab[:badgeNumber].nil? || tab[:badgeNumber] <= 0
          
          if tab[:navigationController]
            controller = UINavigationController.alloc.initWithRootViewController(viewController)
          else
            controller = viewController
          end

          if tab[:title]
            controller.tabBarItem.title = tab[:title]
          else
            controller.tabBarItem.title = viewController.title
          end

          mt_tab_controllers << controller
        end

        tabBarController = UITabBarController.alloc.init
        tabBarController.viewControllers = mt_tab_controllers

        return tabBarController
      end

      def tabBarIcon(icon, tag = 0)
        return UITabBarItem.alloc.initWithTabBarSystemItem(icon, tag: tag)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion-tab-0.1.2 lib/motion-tab/tab_bar.rb