提问人:vc7 提问时间:8/9/2012 最后编辑:vc7 更新时间:8/10/2012 访问量:236
UITableViewCell 的背景图像的高度不会平滑地跟随行的高度
UITableViewCell's background image's height won't smoothly follow the row's height
问:
我们创建了一个列出一些内容,
我们想要一种效果,即背景图像视图将随着行高度的变化而平滑扩展,但我们只是得到了将图像更改为行的最终高度的效果。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”),我将不胜感激你的答案!
我们尝试了其他方法,例如在自定义方法中添加高度变化,这与上面的视频相同UIImageView
UITableViewCell
layoutSubview
谢谢CSmith的回答,我们尝试过这个方法作为背景,但是我们发现我们的问题不在后台,我们会继续寻找解决方案,但谢谢~~ :)
答:
0赞
CSmith
8/9/2012
#1
cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cellbg.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:10.0] ];
评论