如何更改UITabBarItem徽章位置? [英] How to change UITabBarItem Badge position?
本文介绍了如何更改UITabBarItem徽章位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的标签栏现在的样子。
This is how my Tabbar is looking right now.
如何移动徽章,使其与响铃图标的右上角重叠?
How do I move that badge so that it overlaps the top right of the bell icon? Any help is appreciated.
推荐答案
请尝试以下操作:
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)
}
}
}
请注意,tabIndex从1开始
pay attention, tabIndex starts from 1
这篇关于如何更改UITabBarItem徽章位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文