Is there a way to find the frame of a particular UITabBarItem
in a UITabBar
?
Specifically, I want to create an animation of an image \"falling\
You do not need any private API, just use the UITabbar property itemWidth
and itemSpacing
. Set these two values like following:
NSInteger tabBar.itemSpacing = 10;
tabBar.itemWidth = ([UIScreen mainScreen].bounds.size.width - self.tabBarController.tabBar.itemSpacing * (itemsCount - 1)) /itemsCount;
Note this will not impact the size or position of image and title used for UITabBarItem.
And then you can get the ith
item's center x like following:
CGFloat itemCenterX = (tabBar.itemWidth + tabBar.itemSpacing) * ith + tabBar.itemWidth / 2;