Figure out UIBarButtonItem frame in window?

前端 未结 11 1917
臣服心动
臣服心动 2020-11-28 02:58

UIBarButtonItem does not extend UIView, so there is nothing like a frame property.

But is there any way I can get what is it\'s CGRec

11条回答
  •  孤独总比滥情好
    2020-11-28 03:20

    I handled it as follows:

    - (IBAction)buttonClicked:(UIBarButtonItem *)sender event:(UIEvent *)event
    {
        UIView* view = [sender valueForKey:@"view"]; //use KVO to return the view
        CGRect rect = [view convertRect:view.bounds toView:self.view];
        //do stuff with the rect
    }
    

提交回复
热议问题