本文介绍了如何确定UIBarButtonItem在UIToolbar中的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
确定UIToolbar中UIBarButtonItem的x,y位置的最简单方法是什么?
What's the easiest way to determine the x,y location of a UIBarButtonItem in a UIToolbar?
我找到的唯一答案是在知道uibarbuttonitem绘制位置的任何方式.
The only answer I found is in any way to know where uibarbuttonitem has been drawn.
所有建议的答案似乎都太复杂了.应该有一种更简单的方法来获得该死的UIBarButtonItem的位置吗?
All proposed answers seem too complicated. There ought to be a simpler way to get the position of the damn UIBarButtonItem isn't there?
推荐答案
我用了这似乎是最优雅的方式
I used this which seems to be the most elegant way
- (CGRect)frameForBarButtonItem:(UIBarButtonItem *)buttonItem
{
UIView *view = [buttonItem valueForKey:@"view"];
return view ? view.frame : CGRectZero;
}
这篇关于如何确定UIBarButtonItem在UIToolbar中的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!