UIBarButtonItem: How can I find its frame?

前端 未结 16 891
忘掉有多难
忘掉有多难 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:57

    Try this one;

    UIBarButtonItem *item = ... ;
    UIView *view = [item valueForKey:@"view"];
    CGFloat width;
    if(view){
        width=[view frame].size.width;
    }
    else{
        width=(CGFloat)0.0 ;
    }
    

提交回复
热议问题