UITableView用虚线分隔的单元格
问题描述:
我想将分隔符从UITableView更改为虚线。我可以找到的是
UITableViewCellSeparatorStyleBlabla ...
I'd like to change the separator from a UITableView to a dotted line. All I could find is UITableViewCellSeparatorStyleBlabla...
我可以换一些东西吗?我不想使用图片,但如果没有其他方法...
Can I put something else instead? I'd rather not use images, but if there is no other way...
谢谢!
答
尝试以下解决方案:
self.tableView.separatorColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Dottedlineimage"]];
请注意:不要忘记关闭默认分隔符样式
note:Don't forget to turn off the default separator style for the table view in both the solutions: [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
=====================或试试这个=================== ========================
=====================OR TRY THIS===========================================
UIImageView *aLine = [[UIImageView alloc] initWithFrame:CGRectMake(cell.frame.origin.x, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)];
[aLine setImage:[UIImage imageNamed:@"yourDottedImage.png"]];
[cell.contentView addSubview:aLine];
[aLine release];
H帮助:)