Reputation: 315
Im trying to implement my own popup menu from a UITabBar. My app allows users to specify which menus are displayed on the tab bar and I'm not keen on the default "More" button that iOS uses when there are a lot of tab bar items so I would like to create some of the tab bar items to be "Sub menus" that pup up a menu of further buttons. I would like it to pop up from the tabbaritem itself and the order of the tabs may not be the same for every user. So far I can find the tabbaritem the user has selected but next i need to know its location so I can animate a popup menu from that location.
Does anyone know how I could go about finding the frame or position of the selected tabbaritem?
Upvotes: 1
Views: 736
Reputation: 993
You can iterate trough the subviews of your UITabBar
and get only those subviews which are a type of UITabBarButton
class. Then you get the frame of the subviews you are interested in.
List<RectangleF> tabBarButtonFrames = new List<RectangleF>();
foreach (var view in this.tabBarController.TabBar.Subviews) {
if (view.ToString().Contains("UITabBarButton")) {
tabBarButtonFrames.Add(view.Frame);
}
Console.WriteLine(view.ToString() + "\t" + view.Frame.ToString());
}
Note: This link contains more ways of getting the Objective-C class names from poupou
Upvotes: 0