Get the width of a UIBarButtonItem

后端 未结 5 836
-上瘾入骨i
-上瘾入骨i 2020-12-05 05:14

I\'m trying to get the width of a UIBarButtonItem.

This doesn\'t work:

barbuttonitem.customView.frame.size.width

And t

5条回答
  •  暖寄归人
    2020-12-05 06:09

    What about this:

    UIBarButtonItem *item = /*...*/;
    UIView *view = [item valueForKey:@"view"];
    CGFloat width = view? [view frame].size.width : (CGFloat)0.0;
    

提交回复
热议问题