【发布时间】:2012-04-06 02:49:06
【问题描述】:
我的疑问很简单,是否有可能修改 y cordenada a tabBarItem?
我需要这个,因为我想从右到左对齐所有 TabBarItens,因为我的应用程序将在横向模式下工作。
我想要这样的东西:Align icons TabBar
【问题讨论】:
标签: ipad uitabbarcontroller uitabbaritem
我的疑问很简单,是否有可能修改 y cordenada a tabBarItem?
我需要这个,因为我想从右到左对齐所有 TabBarItens,因为我的应用程序将在横向模式下工作。
我想要这样的东西:Align icons TabBar
【问题讨论】:
标签: ipad uitabbarcontroller uitabbaritem
在 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
}
}
【讨论】: