gpt4 book ai didi

ios - 在自定义单元格内动态添加标签

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:16:19 25 4
gpt4 key购买 nike

我在自定义单元格中动态添加 UIlabels,每个标签之间的间隙没有正确对齐。所以,请帮助我解决这个问题。

 cell.lblObj.numberOfLines=0;
cell.lblObj.lineBreakMode = NSLineBreakByWordWrapping;
CGSize maximumLabelSize = CGSizeMake(170,100);
CGSize expectedLabelSize = [strfrom sizeWithFont:cell.lblObj.font
constrainedToSize:maximumLabelSize
lineBreakMode:NSLineBreakByWordWrapping];
CGRect newFrame = cell.lblObj.frame;
newFrame.size.height = expectedLabelSize.height;
cell.lblObj.frame = newFrame;
cell.lblObj.text=strfrom;
[cell.lblObj sizeToFit];

Please Check this screen

 NSString *strfrom=[[mtblarray objectAtIndex:indexPath.row] valueForKey:@"source"];
cell.lblfrom.numberOfLines=0;
cell.lblfrom.lineBreakMode = NSLineBreakByWordWrapping;
CGSize maximumLabelSize = CGSizeMake(170,100);
CGSize expectedLabelSize = [strfrom sizeWithFont:cell.lblfrom.font
constrainedToSize:maximumLabelSize
lineBreakMode:NSLineBreakByWordWrapping];
CGRect newFrame = cell.lblfrom.frame;
newFrame.size.height = expectedLabelSize.height;
cell.lblfrom.frame = newFrame;
cell.lblfrom.text=strfrom;
[cell.lblfrom sizeToFit];
cell.lblfrom.backgroundColor = [UIColor redColor];

最佳答案

关于ios - 在自定义单元格内动态添加标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29648792/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com