gpt4 book ai didi

iphone - 标签边框内的间距

转载 作者:行者123 更新时间:2023-11-28 22:44:49 25 4
gpt4 key购买 nike

friend 们,我创建了一个带边框的 UILabel(如下图所示)。

我想在剩下一/两行后开始我的标签,然后在完成标签的最后一行后再次在下面的一/两行之后开始我的标签。

有什么方法可以让标签边框内有间距吗?

This is the UILabel with border

    UILabel *cmntBoxlbl = [[UILabel alloc]initWithFrame:CGRectMake(58, 23, 250, 60)];
cmntBoxlbl.font=[UIFont fontWithName:@"Arial" size:12];
cmntBoxlbl.layer.borderColor = [UIColor darkGrayColor].CGColor;
cmntBoxlbl.layer.borderWidth = 1.0;
NSString *text = [NSString stringWithFormat:@"%@%@%@",@" ",[[self.DtlArray objectAtIndex:indexPath.row] objectForKey:@"comment"],@" "];
cmntBoxlbl.text = text;

cmntBoxlbl.textAlignment = UITextAlignmentCenter;
cmntBoxlbl.lineBreakMode = UILineBreakModeWordWrap;
[cmntBoxlbl setTextColor:[UIColor darkGrayColor]];

CGSize expectedLabelSize = [text sizeWithFont:cmntBoxlbl.font
constrainedToSize:cmntBoxlbl.frame.size
lineBreakMode:UILineBreakModeWordWrap];

CGRect newFrame = cmntBoxlbl.frame;
newFrame.size.height = expectedLabelSize.height;
cmntBoxlbl.frame = newFrame;
cmntBoxlbl.numberOfLines = 0;
[cmntBoxlbl sizeToFit];
[cell addSubview:cmntBoxlbl];

最佳答案

使当前标签(commentLabel)颜色为白色。创建另一个内容相同但尺寸稍小的标签,将其放在边界内。根据需要进行填充

关于iphone - 标签边框内的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13494613/

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