【问题标题】:UITableViewCell Custom Layout and Border UIBubbleUITableViewCell 自定义布局和边框 UIBubble
【发布时间】:2015-08-13 22:07:35
【问题描述】:

您可能使用过 Messenger iOS App,它有一个不错的UITableViewCell

我到处搜索,所以我搜索到UIBubbleView,但它完全是用 Objective-C 编写的,不幸的是我的背景是 Swift,而且它有很多配置,例如动态单元格高度,支持图片等。

无论如何我都有设计,我已经在 Illustrator 中完成了,但我想知道如何用我设计的 .png 替换 Cell

如有任何建议或教程,我将不胜感激

【问题讨论】:

    标签: xcode swift uitableview


    【解决方案1】:

    要回答您问题的第一部分,这里有一个链接。这是一个定制的 UI,就像任何其他消息传递应用程序一样工作。 https://github.com/badoo/Chatto

    对于问题的第二部分,这可能是一个有用的解决方案。

    对于单元格

    cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cell_normal.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];  
    cell.selectedBackgroundView =  [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cell_pressed.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
    

    对于表格视图

    [mEditTableView setBackgroundView:nil];
    [mEditTableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"apple.png"]] ];
    

    这是一个委托方法,也可以正常工作。

    - (void)tableView:(UITableView *)tableView willDisplayCell (UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{      
     if((indexPath.row)==0)  
       cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_normal.PNG"]]; //set image for cell 0
    
     if (indexPath.row==1)  
       cell.backgroundColor = [UIColor colorWithRed:.8 green:.6 blue:.6 alpha:1]; //set color for cell 1
    
     tableView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"cloud.jpg"]]; //set image for UITableView
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-05
      • 1970-01-01
      • 2020-11-04
      • 1970-01-01
      相关资源
      最近更新 更多