基本分隔符看起来非常简单并且是一维的,但是大多数表格 View 都有一个好看的分隔符,我认为它看起来不错,因为它有阴影或使它看起来像 3D 的东西。他们是怎么做到的?
最佳答案
您可以通过编程/XIB 创建表。 现在在您的代码或 XIB 集中:
yourTable.separatorStyle=UITableViewCellSeparatorStyleNone;
现在在 TableView 委托(delegate)方法中:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:businessLogicIdentifier]
autorelease];
customSeperator=[[UIView alloc]initWithFrame:CGRectMake(0, (cell.frame.origin.y), 320, 1)];
customSeperator.backgroundColor=[UIColor lightGrayColor];
[cell.contentView addSubview:customSeperator];
}
现在在行 (customSeperator.backgroundColor=[UIColor lightGrayColor];) 你也可以尝试
[UIColor colorWithPatternImage:[UIImage imageNamed:@"myimage.png"]];
用于使用您自己的图像。 希望对您有帮助
关于iphone - 如何创建好看的UITableView分隔符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10206909/