objective-c - 行背景被切断

标签 objective-c ios ipad uitableview

我有一张 table ..我尝试在每一行中显示该图像。

The correct image how it should show..

但是当我这样做时

cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BlueLong.png"]];

结果是这样的..

enter image description here

第一行是正确的..但之后它就像图像的上侧被切割..? 我该如何解决这个问题?

已经!

最佳答案

Stretchableimage stretch.png - 这是缩小为阴影和形状的图像

cell.backgroundColor = [UIColor colorWithPatternImage:[[UIImage imageNamed:@"stretch.png"] stretchableImageWithLeftCapWidth:21.0 topCapHeight:15.0]];

21和15是尺寸为42x31像素的图像的中心

编辑:这应该有效

cell.backgroundColor = [UIColor clearColor];
cell.backgroundView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"stretch.png"] stretchableImageWithLeftCapWidth:21 topCapHeight:15]];

关于objective-c - 行背景被切断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7145262/

相关文章:

ios - NSUserDefaults 或存储大型数组时的其他内容?

javascript - 在下一页移动时页脚隐藏

objective-c - 使用 ACAccountStore 时为 "(null) wants to access twitter"

ios - 触摸时自动滚动到 tableviewcell

iOS 应用程序图像/图标位深度

iphone - 具有 clearColor 背景的 UITableView 部分?

iOS 如何在应用程序中实现一个长的、可滚动的日志功能?

iphone - 如何避免在 Core Graphics 中调用 png_read_filter_row 和 transform_premul_argb_fn?

iphone - 如何禁用 UISegmentedControl?

objective-c - 与 azure b2c 获取方案集成的 ios 应用程序没有注册处理程序错误