0

I have UITabBarController with view enter image description here

So on every TabBar I have ViewController. But on my center UITabBarItem I need to call something like modal UIViewController. And It should be like this enter image description here

My UITabBarController class look like

class PlanetTabBarController: UITabBarController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBar.tintColor = kTintColor

        var items = self.tabBar.items as! [UITabBarItem]
        let centredTabBar:UITabBarItem = items[2]
        self.tabBar.layer.borderWidth = 0.50

        centredTabBar.image = ktabCentredBarImage
        self.tabBar.layer.borderColor = UIColor.clearColor().CGColor
        self.tabBar.layer.borderWidth = 0

        self.tabBar.shadowImage = UIImage()
        // self.tabBar.backgroundImage = ktabBarImage
        self.tabBar.backgroundImage?.imageWithAlignmentRectInsets

        print( UIDevice.currentDevice().modelName)
        if( UIDevice.currentDevice().modelName != "iPhone 6" && UIDevice.currentDevice().modelName != "iPhone 6 Plus") {
           self.tabBar.backgroundImage = ktabBarImage 
        }
        if( UIDevice.currentDevice().modelName == "iPad 2" ) {
            self.tabBar.backgroundImage = ktabBarImage
        }

        if let font = UIFont(name: "Avenir-Black", size: 10) {
            let appearance = UITabBarItem.appearance()
            let attributes = [NSFontAttributeName:font]
            appearance.setTitleTextAttributes(attributes, forState: UIControlState.Normal)
        }
    }
}

I really have no idea how to override standart calling of UIViewController and call modal like this =) Please give me advice where I need to search

Ninjakannon
  • 3,751
  • 7
  • 53
  • 76
nabiullinas
  • 1,185
  • 4
  • 20
  • 41
  • 1
    What is the question? To create a custom UITabBarItem? Are you simply wanting to present a view if someone touches that center planet image? – Mark McCorkle Apr 22 '15 at 16:45
  • I need to show popupView after tapping on the center UITabBarItem. Do not show ViewController on all screen as standart - just show modal viewcontroller – nabiullinas Apr 22 '15 at 18:30

1 Answers1

0

You can either place a UIButton in the same area as the UITabBarItem and fire an action or you can simply fire an action when the selectedSegmentIndex changes("value changed" in IB) for the UITabBar after creating a center UITabBarItem. The design choice is yours. The first step is to understand the objects you're working with. It would probably be easier to just add a button, center aligned, over top of the standard UITabBar at the bottom so you don't deal with a custom UITabBarController to handle that non-uniform image above the tab bar.

Or just create your own TabBar down there. It's very simply to setup a few UIButtons or UIViews next to one another that don't have a static height such as a UITabBarController which would allow for that center object.

UITabBarController

UIViewController

Presenting a ViewController

Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42