4

well my doubt is simple, there is the possibility to modify the y cordenada a tabBarItem?

I need this because I want to align all TabBarItens from right to left, because my app will work in Landscape mode.

I want something like this: Align icons TabBar

Community
  • 1
  • 1
jucajl
  • 1,195
  • 3
  • 12
  • 29

1 Answers1

0

Do this in YourTabBarButton class:

public class YourTabBarItem: UITabBarItem {
    @IBInspectable public var tintColor: UIColor?
    @IBInspectable public var rightToLeft:Bool = false
}

public class YourTabBarButton: UIControl {
    override public func layoutSubviews() {
            super.layoutSubviews()
            tabBg.layer.cornerRadius = tabBg.bounds.height / 2.0
            let offset = CGFloat(6)
            tabBg.layer.frame.size.width = tabBg.layer.frame.size.width - 2 * offset
            tabBg.frame.origin.y = tabBg.frame.origin.y - offset
            tabBg.frame.origin.x = tabBg.frame.origin.x + offset
            tabLabel.frame.origin.y = tabLabel.frame.origin.y - offset
            tabImage.frame.origin.y = tabImage.frame.origin.y - offset
        }
}
Nima Ganji
  • 561
  • 8
  • 17