我是 iPhone 开发的新手。
我知道可能有与我的问题相关的答案,但没有一个对我有帮助。
根据标题,我有带分组样式的 UITableView。 我想设置背景图片,但设置不正确。
但问题是如我的屏幕截图中所述。
好吧,我想显示由UITableView
(grouped) 的cells
描述的我的 ImageView 区域
这是我的代码:
self.tblView = [[UITableView alloc]initWithFrame:CGRectMake(0, 125, 320, 320) style:UITableViewStyleGrouped];
UIImageView *bgTableImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,0, 320, 320)];
bgTableImageView.image = [UIImage imageNamed:@"bgImage.png"];
self.tblView.backgroundColor=[UIColor clearColor];
[self.tblView setBackgroundView:bgTableImageView];
//self.tblView.backgroundView = nil;
// self.tblView.opaque = NO;
//self.tblView.bounces = NO;
//self.tblView.scrollEnabled = YES;
self.tblView.delegate=self;
self.tblView.dataSource=self;
self.tblView.separatorColor = [UIColor darkGrayColor];
self.tblView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
[self.view addSubview:self.tblView];
所有其他的都工作正常,我只有 How to set background image of UITableViewStyleGrouped
的问题?
最佳答案
试试这个:
UIImageView *av = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 277, 58)];
av.backgroundColor = [UIColor clearColor];
av.opaque = NO;
av.image = [UIImage imageNamed:@"categorytab1.png"];
cell.backgroundView = av;
关于objective-c - 如何正确设置分组 TableView 的背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15922454/