![](/img/trans.png)
[英]show progress indicator for multiple image upload in UITableViewCell
[英]UITableViewCell as progress indicator
我正在嘗試設置整個單元格背景視圖以顯示進度指示器。
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
cell.backgroundView = progressView;
[progressView setFrame:cell.bounds];
}
這不會將進度條設置到整個單元格,而只是設置單元格的頂部。 我應該如何使細胞透明嗎? 我如何使用整個單元格背景以顏色填充顯示進度,而單元格上的文本仍然可見?
我認為,除了progress View之外,如果您可以在cellForRowAtIndexPath:
使用它cellForRowAtIndexPath:
cell.backgroundColor = [UIColor clearColor];
CGFloat fillWidth = (75.0/100.0) * cell.frame.size.width;
CGRect rect = CGRectMake(0, 0, fillWidth, cell.frame.size.height);
UIView * view = [[UIView alloc] initWithFrame:rect];
view.backgroundColor = [UIColor purpleColor];
[cell.contentView addSubview:view];
//...
return cell;
您需要設置UIProgressView的高度並將其添加為單元格的內容子視圖,如下所示:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
//setting height of progressView
CGAffineTransform transform = CGAffineTransformMakeScale(cell.frame.size.width, cell.frame.size.height);
progressView.transform = transform;
[cell.contentView addSubview:progressView];
//your text
cell.textLabel.text = @"Cell Text Label";
cell.detailTextLabel.text = @"Cell Detail Label";
}
return cell;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.