How to determine position of UIBarButtonItem in UI

2020-05-23 11:28发布

What's the easiest way to determine the x,y location of a UIBarButtonItem in a UIToolbar?

The only answer I found is in any way to know where uibarbuttonitem has been drawn.

All proposed answers seem too complicated. There ought to be a simpler way to get the position of the damn UIBarButtonItem isn't there?

7条回答
相关推荐>>
2楼-- · 2020-05-23 11:52
UIToolbar *toolbar;

for (UIView *v in [toolbar items]) 
{
    if ([v isKindOfClass:[UIBarButtonItem class]])
    {
        UIBarButtonItem *b = (UIBarButtonItem*)v;
        //do something with b..
    }
}
查看更多
登录 后发表回答