iOS tableViewCell最右边显示箭头,字符,自定义分割线

效果如图:
image.png
1.添加iOS系统自带的cell的箭头

cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

2.去掉tableviewcell的间隔下划线

_tableView.separatorStyle=UITableViewCellSeparatorStyleNone;

3.添加自定义间隔线,加在下面的这个方法里面

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

//这里

}

如下:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

UIView*lbl = [[UIViewalloc]init];//定义一个label用于显示cell之间的分割线(未使用系统自带的分割线),也可以用view来画分割线

lbl.frame= CGRectMake(cell.frame.origin.x+10, cell.frame.size.height-5, cell.frame.size.width-20,1);

lbl.backgroundColor=  [UIColorlightGrayColor];

[cell.contentViewaddSubview:lbl];

}

转载:
1.iOS:tableViewCell最右边显示箭头,字符,自定义分割线

2.iOS TableView去掉最后一行Cell的分割线

3.IOS TableView去掉最后一个cell分割线简单方法

4.iOS自定义TableView的Cell点击事件

猜你喜欢

转载自blog.csdn.net/xiao19911130/article/details/109078523
今日推荐