I have a button in a toolbar. How can I grab its frame? Do UIBarButtonItems not have a frame property?
Here's the way to do it:
-(CGRect)findFrameOfBarButtonItem{
for (UIView *view in self.navigationController.navigationBar.subviews)
{
if ([view isKindOfClass:NSClassFromString(@"_UINavigationBarContentView")])
{
UIView * barView = [self.navigationItem.rightBarButtonItem valueForKey:@"view"];
CGRect barFrame = barView.frame;
CGRect viewFrame = [barView convertRect:barFrame toView:view];
return viewFrame;
}
}
return CGRectZero;
}