UIBarButtonItem: How can I find its frame?

前端 未结 16 897
忘掉有多难
忘掉有多难 2020-12-12 23:17

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

16条回答
  •  天命终不由人
    2020-12-12 23:56

    Thanks to Anoop Vaidya for the suggested answer. An alternative could be (providing you know the position of the button in the toolbar)

    UIView *view= (UIView *)[self.toolbar.subviews objectAtIndex:0]; // 0 for the first item
    
    
    CGRect viewframe = view.frame;
    

提交回复
热议问题