【发布时间】: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 50 或return 250
但是这里显然有一些问题,我该如何解决?我到处都是谷歌,有些应用会产生这种效果(比如“DOOO”),我会很感激你的回答!
我们尝试了其他方法,例如在自定义 UITableViewCell 的 layoutSubview 方法中添加 UIImageView 高度变化,这与上面的视频相同
感谢CSmith的回答,我们已经尝试过这种方法用于后台,但我们发现我们的问题不在后台,我们会继续寻找解决方案,但是谢谢~~:)
【问题讨论】:
标签: ios uitableview