2016-08-16 2 views
3

Voici à quoi ressemble mon Tabbar en ce moment.Comment changer la position du badge UITabBarItem?

enter image description here

Comment déplacer cet insigne afin qu'il recouvre la partie supérieure droite de l'icône de cloche? Toute aide est appréciée.

+0

voir ce http://stackoverflow.com/questions/24236823/how-to-adjust-tab-bar-badge- position –

+0

Possible duplicata de [position de badge iOS 7 UITabBar] (http://stackoverflow.com/questions/19165671/ios-7-uitabbar-badge-position) – chrs

Répondre

5

essayez ceci:

func repositionBadge(tabIndex: Int){ 

    for badgeView in self.tabBarController!.tabBar.subviews[tabIndex].subviews { 

     if NSStringFromClass(badgeView.classForCoder) == "_UIBadgeView" { 
      badgeView.layer.transform = CATransform3DIdentity 
      badgeView.layer.transform = CATransform3DMakeTranslation(-17.0, 1.0, 1.0) 
     } 
    } 
} 

attention de salaire, tabIndex commence à partir de 1

+2

Attention: ceci utilise l'API privée, Apple pourrait rejeter votre application pour l'utiliser ce. – Louis