Fel*_*lix 90
将separatorStyletableview 设置为UITableViewCellSeparatorStyleNone.将分隔符图像作为子视图添加到每个单元格并正确设置框架.
Sak*_*shi 59
试试这个
目标C.
[TableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
[TableView setSeparatorColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Divider_line@2x.png"]]];
Run Code Online (Sandbox Code Playgroud)
迅速
tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine
tableView.separatorColor = UIColor(patternImage: UIImage(named: "YOUR_IMAGE_NAME")!)
Run Code Online (Sandbox Code Playgroud)
Tom*_*yer 29
首先你可以编写代码:
{ [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];}
Run Code Online (Sandbox Code Playgroud)
之后
{ #define cellHeight 80 // You can change according to your req.<br>
#define cellWidth 320 // You can change according to your req.<br>
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seprater_line.png"]];
imgView.frame = CGRectMake(0, cellHeight, cellWidth, 1);
[customCell.contentView addSubview:imgView];
return customCell;
}
}
Run Code Online (Sandbox Code Playgroud)
使用图像设置要图案化的分隔符的颜色.
在viewDidLoad:
self.tableView.separatorColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"mySeparatorImage"]];
Run Code Online (Sandbox Code Playgroud)
我的项目基于iOS 7这对我有帮助
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
然后将子视图放入单元格作为分隔符!
例如,您可以添加一个 UIImageView,其高度为 1 磅,宽度与单元格的框架相同,然后将其原点设置为单元格的左下角。