【问题标题】:Change y position of a UITabBarItem更改 UITabBarItem 的 y 位置
【发布时间】:2012-04-06 02:49:06
【问题描述】:

我的疑问很简单,是否有可能修改 y cordenada a tabBarItem?

我需要这个,因为我想从右到左对齐所有 TabBarItens,因为我的应用程序将在横向模式下工作。

我想要这样的东西:Align icons TabBar

【问题讨论】:

    标签: ipad uitabbarcontroller uitabbaritem


    【解决方案1】:

    在 YourTabBarButton 类中执行此操作:

    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
            }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-12-22
      • 1970-01-01
      • 1970-01-01
      • 2012-04-28
      • 1970-01-01
      • 1970-01-01
      • 2021-08-30
      • 2018-12-15
      • 2012-06-19
      相关资源
      最近更新 更多