【问题标题】:UITableViewCell's background image's height won't smoothly follow the row's heightUITableViewCell 的背景图片高度不会平滑地跟随行的高度
【发布时间】:2012-08-08 18:29:42
【问题描述】:

我们创建了一个UITableviewController 来列出一些内容, 我们想要一个背景图像视图会随着行高的变化而平滑扩展的效果,但我们只是得到了图像更改为最终行高的效果。

视频是我们得到的: http://www.youtube.com/watch?v=v-5TtrpYhl8

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 中,我们只需在单元格中添加一个子视图,如下所示

UIImage *cellBackgroundImage = [UIImage imageNamed:@"cellbg.png"];
UIImageView *cellBackgroundImageView = [[UIImageView alloc] init];
[cellBackgroundImageView setImage:[cellBackgroundImage stretchableImageWithLeftCapWidth:10 topCapHeight:10]];
[cell addsubview:cellBackgroundImageView]

不仅仅是在-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 中设置高度,例如return 50return 250

但是这里显然有一些问题,我该如何解决?我到处都是谷歌,有些应用会产生这种效果(比如“DOOO”),我会很感激你的回答!


我们尝试了其他方法,例如在自定义 UITableViewCelllayoutSubview 方法中添加 UIImageView 高度变化,这与上面的视频相同


感谢CSmith的回答,我们已经尝试过这种方法用于后台,但我们发现我们的问题不在后台,我们会继续寻找解决方案,但是谢谢~~:)

【问题讨论】:

    标签: ios uitableview


    【解决方案1】:

    参考UITableView cell with background image

    cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cellbg.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:10.0] ];   
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-04
      • 1970-01-01
      • 2011-04-05
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      相关资源
      最近更新 更多