【发布时间】:2014-02-02 16:34:24
【问题描述】:
我正在尝试根据其中的文本(或我允许 ie108 的最大宽度)重新调整标签的大小,并在它旁边放置一个按钮,下面的代码实际上在调试时给出了令人满意的结果,但标签的宽度是不相应改变。 在 xib 或其他任何东西中是否有任何特殊设置可做请帮助我。
NSDictionary *attrib=@{NSFontAttributeName:locFeedcell.lbl_location.font};
CGFloat width=[locFeedcell.lbl_location.text sizeWithAttributes:attrib].width;
CGRect newLabelframe=locFeedcell.lbl_location.frame;
CGRect newButtonFrame=locFeedcell.btn_map.frame;
if (width>=108.00f) {
newLabelframe.size.width=108.00;
} else {
newLabelframe.size.width=width;
newButtonFrame.origin.x=locFeedcell.lbl_location.bounds.origin.x+width+4.00;
}
locFeedcell.lbl_location.frame=newLabelframe;
locFeedcell.btn_map.frame=newButtonFrame;
这是 xib 文件的快照。
【问题讨论】: