Ios UITableViewCell添加了自定义视图加载问题
您好,我想为我的Ios UITableViewCell添加了自定义视图加载问题,ios,objective-c,uitableview,Ios,Objective C,Uitableview,您好,我想为我的UITableView添加自定义单元格分隔符,以便在我的cllforrowatinex委托中 if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier] } 在此之后,我将自定义UIView添加到我的cell.content视图中 UIView *lineView =
UITableView
添加自定义单元格分隔符,以便在我的cllforrowatinex
委托中
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]
}
在此之后,我将自定义UIView
添加到我的cell.content视图中
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.contentView.frame.size.height - 1.0, cell.contentView.frame.size.width, 1)];
lineView.backgroundColor = [UIColor colorWithRed:61.0/255 green:80.0/255 blue:118.0/255 alpha:1.0];
[cell.contentView addSubview:lineView];
但我的问题是,当它第一次加载时,我的分隔器右侧不会进入UITableView
的edg,但一旦我滚动了表格,它就会转到全宽。为什么呢?我怎样才能解决这个问题
UITableViewCell
layoutSubviews
方法中设置分隔符的框架[self.tableView setSeparatorColor:[UIColor myColor]];
或者我们不能更改默认分隔符颜色吗?您可以,这很容易
[self.tableView setSeparatorColor:[UIColor myColor]]代码>