我正在为我的细胞背景使用渐变。但是,如果我使用
gradient.Frame = this.Bounds
它使用UITableViewCell
的默认高度。我尝试使用GetHeightForRow
函数以及this.TableView.RowHeight = 60
,但每次渐变都具有单元格默认高度的高度。
目前我正在使用
gradient.Frame = new RectangleF (this.Bounds.X, this.Bounds.Y, this.Bounds.Width, 60);
但Bounds
是否有正确的高度(例如,设置为RowHeight
)?
代码适用于C#,但Objective-C解决方案非常相似。
答案 0 :(得分:0)
好吧,我认为你想要的是这样的......在你的表视图中,委托方法设置如下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell = [tableView dequeueReusableCellWithIdentifier:@"ReusableCellID"];
UIImage* image = [UIImage imageNamed:@"gradient.png"];
UIImageView* imgView = [[UIImageView alloc] initWithFrame:CGRectMake:(cell.frame.origin.x,cell.frame.origin.y,cell.frame.size.width,cell.frame.size.height)];
imgView.image = image;
[cell.backgroundView addSubview:imgView];
return cell;
}