2012-03-03 110 views
1

我想有一个像这样的桌面边框样式,只有左侧是彩色的。UITableView单面边框颜色?

example image http://i40.tinypic.com/14kgvbk.jpg

任何想法?

+1

许多想法!你目前的做法是什么?你有什么问题? – phi 2012-03-03 07:26:51

+0

我尝试使用CALayer和SetBorderWidth和SetBorderColor,但它设置了整个边界。我只想要在广告牌应用照片中显示的左侧。 – 2012-03-03 07:29:06

+0

在tablewview上方添加不透明视图,您将会看到它。另外,如果单元格之间没有分隔符,则可以将这种视图添加到它们中。 – 2012-03-03 07:39:34

回答

1

一个简单的方法是将UIImageView添加到与单元格宽度相同且高度相同的单元格中(example)。另一种方法是使用图像作为每个单元格的背景,并在您将使用的实际图形中添加此边框(example)。如果你想在层次上做到这一点,一个好的开始是this example。我希望这有助于!

5

我能想到的最简单方法是在内容视图中添加少许的看法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 
     //Just a small view 
     UIView *lineView=[[UIView alloc] initWithFrame:CGRectMake(X_POS, Y_POS, LINE_WIDTH, CELL_HEIGHT)]; 
     [lineView setBackgroundColor:[UIColor redColor]]; 
     [[cell contentView] addSubview:lineView]; 
     [lineView release]; 

    } 
    return cell; 
}