1

I have added tabbar control to my view controller through the story board, with following constraints.. enter image description here

As i required the selection indicator image for the selected item i am using following code in viewDidLayoutSubviews method

override func viewDidLayoutSubviews(){
super.viewDidLayoutSubviews();
viewForTab.setShadow(shadowColor: UIColor.gray.cgColor, shadowOffset:CGSize.init(width: 0.0, height: 3.0), shadowOpacity: 0.8, shadowRadius: 3.0)

tabBar.selectionIndicatorImage = APPDELEGATE.getImageWithColorPosition(color: UIColor.themeSectionBackgroundColor, size: CGSize.init(width: viewForTab.frame.width/2, height: viewForTab.frame.height ), lineSize: CGSize.init(width: viewForTab.frame.width/2, height: 1.5))

}

It get perfect effect in iPhone but in ipad the ui get ugly, As you can see in below image, Login and Register Text are not aligned center and also the indicator put the space from left side of uitabbar item but in iphone it works perfectly.

Cant identify the issue..

enter image description here

Jaydeep Vyas
  • 4,411
  • 1
  • 18
  • 44

1 Answers1

4

Make class of UITabBar and give class of UITabBar from Stroyboard

class TabBar: UITabBar {

    override var traitCollection: UITraitCollection {
        guard UIDevice.current.userInterfaceIdiom == .pad else {
            return super.traitCollection
        }

        return UITraitCollection(horizontalSizeClass: .compact)
    }
}

Hope it helps

Kamlesh Shingarakhiya
  • 2,757
  • 2
  • 16
  • 34