Open xcodewarrier opened 8 years ago
Hi @xcodewarrier
There is not a best way to approach this as far as I know, just hacks that call the private view
of the button: http://stackoverflow.com/questions/14318368/uibarbuttonitem-how-can-i-find-its-frame
+1
This would be a great feature to add a way to support this. It's a rather common use case.
try this:
private func frameForTabAtIndex(index: Int) -> CGRect {
guard let tabBarSubviews = tabBarController?.tabBar.subviews else {
return CGRect.zero
}
var allItems = [UIView]()
for tabBarItem in tabBarSubviews {
if tabBarItem.isKind(of: NSClassFromString("UITabBarButton")!) {
allItems.append(tabBarItem)
}
}
let item = allItems[index]
return item.superview!.convert(item.frame, to: view)
}
I have the same query as @xcodewarrier. Any update on it?
Is it possible to use this with a UIBarButtonItem?
leftBarButtonItem could be hacked as it will always be on the top left of the view, but what abut a rightBarButtonItem?