Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIBarButtonItem: How can I find its frame?

I have a button in a toolbar. How can I grab its frame? Do UIBarButtonItems not have a frame property?

like image 725
totalitarian Avatar asked Jan 14 '13 12:01

totalitarian


2 Answers

Try this one;

UIBarButtonItem *item = ... ; UIView *view = [item valueForKey:@"view"]; CGFloat width; if(view){     width=[view frame].size.width; } else{     width=(CGFloat)0.0 ; } 
like image 125
Anoop Vaidya Avatar answered Sep 21 '22 20:09

Anoop Vaidya


This way works best for me:

UIView *targetView = (UIView *)[yourBarButton performSelector:@selector(view)]; CGRect rect = targetView.frame; 
like image 30
MobileMon Avatar answered Sep 23 '22 20:09

MobileMon