UIBarButtonItem:我怎样才能找到它的框架? [英] UIBarButtonItem: How can I find its frame?

查看:76
本文介绍了UIBarButtonItem:我怎样才能找到它的框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在工具栏中有一个按钮。我怎么能抓住它的框架? UIBarButtonItem 是否没有框架属性?

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

推荐答案

试试这个;

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

这篇关于UIBarButtonItem:我怎样才能找到它的框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆