gpt4 book ai didi

ios - iOS7 上错误的 UITableView 分隔符颜色

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:02:24 26 4
gpt4 key购买 nike

我以这种方式设置 UITableView 分隔符颜色:

- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.separatorColor = [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.1f];
}

iOS7 上,SOMETIMES 我的表格 View 分隔符看起来不同(我猜带有数据的单元格和空单元格分隔符具有不同的 alpha),请看附图: enter image description here

我该如何解决这个问题?

最佳答案

如果要删除所有内容为空的单元格分隔符,请使用以下代码行。

self.tableView.tableFooterView = [[UIView alloc] init]; 

viewDidLoad 方法中。

其他方式设置self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 并为分隔符设置自定义UIImage

例子:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = @"cell"; //[NSString stringWithFormat:@"S%1dR%1d", indexPath.section, indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
.
. // your other code.
.
UIImageView *imgLine = [[UIImageView alloc] init];
imgLine.tag = 101;
[cell.contentView addSubview: imgLine];
}

.
. // your other code.
.

UIImageView *imgLine = (UIImageView *) [cell.contentView viewWithTag:101];
imgLine.frame = CGRectMake(5, 69, 310, 1);
imgLine.image = [UIImage imageNamed:@"queTblLine.png"];

return cell;
}

并且不要忘记设置 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

编辑:不确定,但可能对您的情况有帮助:

设置 self.tableView.separatorInset = UIEdgeInsetsZero;

获取From question/answer.

关于ios - iOS7 上错误的 UITableView 分隔符颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21829578/

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