【问题标题】:How to create UITableView separator look good?如何创建 UITableView 分隔符好看?
【发布时间】:2012-04-18 09:49:29
【问题描述】:

基本的分隔符看起来很简单并且是一维的,但是大多数表格视图都有很好看的分隔符,我觉得它看起来不错,因为它有阴影或使它看起来像 3D 的东西。他们是怎么做到的?

【问题讨论】:

标签: iphone objective-c uitableview


【解决方案1】:

您可以通过编程方式/XIB 创建您的表格。 现在在您的代码或 XIB 集中:

yourTable.separatorStyle=UITableViewCellSeparatorStyleNone;  

现在在 tableview 委托方法中:

- (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"]];  

用于使用您自己的图像。 希望对你有帮助

【讨论】:

  • 谢谢,最终我为我的单元格创建了一个包含分隔符的背景图像,我认为这对我来说是最好的解决方案:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-31
  • 1970-01-01
  • 1970-01-01
  • 2017-07-06
  • 2010-10-02
  • 2012-08-04
相关资源
最近更新 更多