Getting the frame of a particular tab bar item

前端 未结 12 1045
礼貌的吻别
礼貌的吻别 2021-02-02 07:42

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\

12条回答
  •  旧时难觅i
    2021-02-02 07:53

    Tab bar buttons are the only sub views that have user interaction enabled. Check for this instead of UITabBarButton to avoid violating hidden API's.

    for (UIView* view in self.tabBar.subviews)
        {
            if( [view isUserInteractionEnabled] )
            {
                [myMutableArray addObject:view];
            }
    }
    

    Once in the array, sort it based on the origin x, and you will have the tab bar buttons in their true order.

提交回复
热议问题