I would like to draw rectangles in the background of the cells of a table view, whose size will indicate the progression of subsequent tasks:
The progression bar should take the whole height of the cell and its width will be programmatically set when the TableView
is shown.
I would like to know how to get this result with a simple and efficient approach. I have not been able to find good practices for drawing a custom background for UITableViewCell
s, using CALayer
or another solution.
Also, I would appreciate if the technical solution for this task could also be valid when deciding to animate the progression of the bars.
Thank you.
答案 0 :(得分:1)
Simple solution without calculation is that, prepare a set of static different background images, and set them depend on the progress value.
答案 1 :(得分:0)
Other solution requires you to create Progress view programmatically in table view's cellForRowAtIndex method and add to cell.contentView as subview
UIProgressView *progressView = [[UIProgressView alloc] init];
[progressView setFrame:cell.frame];
[cell.contentView insertSubview:progressView atIndex:0];
You can make progressview alpha property to 0.5 or some other value in order for your top views in cell.contentView to be visible properly