[英]UILabel in UITableView setting size
我想將標簽子視圖添加到UITableViewCell。 我可以輕松地將幀原點和尺寸設置為特定值,但是如何使用當前/默認單元格標簽的高度和位置?
UILabel *labPerHour;
cell.textLabel.text = @"Rate";
labPerHour = [[UILabel alloc] init];
//labPerHour.frame = CGRectMake( 280, cell.textLabel.frame.origin.y, 80, cell.textLabel.frame.size.height );
labPerHour.frame = CGRectMake( 260, 7, 30, 30 );
labPerHour.text = @"$/hr";
[cell addSubview:labPerHour];
我希望注釋掉的行可以工作..或類似的東西。
有人可以幫忙嗎? 這段代碼當然是我的cellForRowAtIndexPath方法的一部分。
我不確定。 可能會起作用。 我以前沒有嘗試過!
CGRect theFrame = cell.textLabel.frame;
theFrame.origin.x = 280;
theFrame.size.width = 80;
labPerHour.frame = theFrame;
如果您嘗試獲取可查看視圖的默認標簽框架,則可以嘗試此操作
CGRect myframe;
myframe= cell.textlabel.frame;
現在根據需要使用它
您首先需要設置單元格標簽框架。
cell.textLabel.frame = CGRectMake(0, 0, 40, 10);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.