【发布时间】:2014-01-09 19:04:34
【问题描述】:
我在将 textLabel 和 detailTextLabel 定位到自定义 UITableViewCell 中时遇到问题,该 UIImageView 出现在 textLabel 和 detailTextLabel 后面。
参考图片 - 它会更有意义 --> 你正在寻找一个 UITableView,其中每个气泡代表一个不同的 UITableViewCell。
本质上,我试图通过扩展气泡尺寸将 textLabel 和 detailTextLabel 放入您看到的气泡中。但是,无论我尝试什么,即使我更改 UIImageView 框架或边界或 contentMode,气泡也不会改变它的宽度和高度。
这是cellForRowAtIndexPath中的相关代码:
//Set font and style
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
// Assign our own background image for the cell
UIImage *cellBackgroundImage = [UIImage imageNamed:@"Chat.png"];
UIImageView *cellBackgroundImageView = [[UIImageView alloc] initWithImage:cellBackgroundImage];
//[cellBackgroundImageView setBounds:CGRectMake(0, 0, 20, 20)];
//[cellBackgroundImageView setImage:cellBackgroundImage];
//cellBackgroundImageView.frame = CGRectMake(cellBackgroundImageView.frame.origin.x, cellBackgroundImageView.frame.origin.y, 20, 20);
//cellBackgroundImageView.bounds = CGRectMake(cellBackgroundImageView.frame.origin.x, cellBackgroundImageView.frame.origin.y, 0, 0);
cellBackgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
cellBackgroundImageView.image = cellBackgroundImage;
cell.backgroundView = cellBackgroundImageView;
任何帮助将不胜感激。
【问题讨论】:
标签: ios objective-c uitableview uiimageview uiimage