【问题标题】:How to adjust Tab bar badge position when using custom tab bar image and inset without tab bar title?使用自定义标签栏图像和没有标签栏标题的插图时如何调整标签栏徽章位置?
【发布时间】:2019-05-04 07:53:19
【问题描述】:

我无法像往常一样将徽章重新定位到默认位置。我已经尝试过这个解决方案,还有一些,但没有一个工作。 How to adjust tab bar badge position?

我的问题可能是标签栏图像而不是徽章位置。我在标签栏图像大小、插图等方面玩了很多,但似乎都不起作用。

有人知道怎么解决吗?

【问题讨论】:

    标签: ios swift uitabbarcontroller badge


    【解决方案1】:
    func repositionBadge(tab: Int){
    
       for badgeView in self.tabBarController!.tabBar.subviews[tab].subviews {
    
           if NSStringFromClass(badgeView.classForCoder) == "_UIBadgeView" {
              badgeView.layer.transform = CATransform3DIdentity
              badgeView.layer.transform = CATransform3DMakeTranslation(-17.0,   1.0, 1.0)
            }
        }
    
    }
    

    请注意制表符整数不是零索引的,因此第一个制表符将是数字 1,第二个数字是 2,依此类推。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-07
      • 2018-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-30
      • 2017-08-23
      • 2023-04-08
      相关资源
      最近更新 更多