Bam*_*a91 8 iphone cocoa-touch uitableview uilabel
我在自定义UITableViewCell的contentView中有一个UILabel数组.通过排序来确定每个标签的字体大小以形成标签云.在设置单元格(行)的方法中,我遍历适合该行的单词对象,为每个UILabel设置框架,如下所示:
CGRect theFrame = CGRectMake(xPosAdjuster,
theWordRow.rowHeight - thisWord.lblHeight,
thisWord.lblWidth,
thisWord.lblHeight);
UILabel *myLabel = [[UILabel alloc] initWithFrame:theFrame];
Run Code Online (Sandbox Code Playgroud)
这会使标签的帧对齐(请参见下图),但不幸的是,标签的填充是字体大小的函数.

有没有办法删除UILabel上的填充(边框)和/或完全计算它,以便我可以相应地调整帧的y位置?
谢谢
Bam*_*a91 10
这是我的标签排列的最终代码:
CGRect theFrame = CGRectMake(xPosAdjuster,
floor(theWordRow.rowHeight - thisWord.lblHeight),
floor(thisWord.lblWidth),
thisWord.lblHeight);
UILabel *myLabel = [[UILabel alloc] initWithFrame:theFrame];
...
CGRect newFrame = myLabel.frame;
newFrame.origin.y -= floor(myLabel.font.descender);
myLabel.frame = newFrame;
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
4698 次 |
| 最近记录: |