gpt4 book ai didi

objective-c - 为什么我有这种奇怪的间距

转载 作者:行者123 更新时间:2023-11-29 04:20:26 25 4
gpt4 key购买 nike

我无法摆脱第 0 行和第 1 行之间这种奇怪的间距。我希望第 0 行和第 1 行之间的间距与第 1 行和第 2 行之间的间距相同。

enter image description here

[self.tableView setBackgroundColor:TABLE_VIEW_BACKGROUND_COLOR];

UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 250)];

UIImageView *headerBackgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"addres_box"]];
[headerBackgroundImageView setFrame:CGRectMake(headerView.frame.origin.x + 10, headerView.frame.origin.y + 10, headerView.frame.size.width - 20, 160)];
[headerView addSubview:headerBackgroundImageView];

UILabel *headerTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(headerBackgroundImageView.frame.origin.x + 10, headerBackgroundImageView.frame.origin.y + 10, headerBackgroundImageView.frame.size.width - 20, 20)];
[headerTextLabel setBackgroundColor:[UIColor clearColor]];
[headerTextLabel setFont:[UIFont boldSystemFontOfSize:headerTextLabel.font.pointSize]];
[headerTextLabel setTextColor:[UIColor whiteColor]];
[headerTextLabel setLineBreakMode:UILineBreakModeTailTruncation];
[headerTextLabel setNumberOfLines:0];

NSString *headerTextString = @"0";
NSString *detailTextString = @"1\n2";

[headerTextLabel setText:headerTextString];
[headerView addSubview:headerTextLabel];
_headerTextLabel = headerTextLabel;

UILabel *headerDetailTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(headerTextLabel.frame.origin.x, headerTextLabel.frame.origin.y+20, headerTextLabel.frame.size.width, 140)];
[headerDetailTextLabel setBackgroundColor:[UIColor clearColor]];
[headerDetailTextLabel setTextColor:[UIColor whiteColor]];
[headerDetailTextLabel setLineBreakMode:UILineBreakModeTailTruncation];
[headerDetailTextLabel setNumberOfLines:0];

[headerDetailTextLabel setText:detailTextString];
[headerView addSubview:headerDetailTextLabel];
_headerDetailTextLabel = headerDetailTextLabel;

[self.tableView setTableHeaderView:headerView];
[self.tableView setSeparatorColor:TABLE_VIEW_SEPARATOR_COLOR];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];

希望有人能帮助我!

最佳答案

也许您的 headerDetailTextLabel 垂直居中,请尝试添加更多行,例如“1\n2\n3\n4”并查看结果。

关于objective-c - 为什么我有这种奇怪的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13045614/

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