I have a button in a toolbar. How can I grab its frame? Do UIBarButtonItem
s not have a frame
property?
Try this one;
UIBarButtonItem *item = ... ; UIView *view = [item valueForKey:@"view"]; CGFloat width; if(view){ width=[view frame].size.width; } else{ width=(CGFloat)0.0 ; }
This way works best for me:
UIView *targetView = (UIView *)[yourBarButton performSelector:@selector(view)]; CGRect rect = targetView.frame;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With