2016-03-10 102 views

回答

4

这很容易。

只需在背景中放置一个视图,从0宽度开始,在tableview/tableview单元格的右侧,然后将其设置为超级视图的整个宽度。

代码段(在斯威夫特游乐场的形式)

进口的UIKit 进口XCPlayground

let tableView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 200)) 
tableView.backgroundColor = UIColor.whiteColor() 

var animatedBackroundColorView = UIView(frame: CGRect(x: tableView.frame.width, y: tableView.frame.origin.y, width: tableView.frame.width, height: tableView.frame.height)) 
animatedBackroundColorView.backgroundColor = UIColor.orangeColor() 
tableView.addSubview(animatedBackroundColorView) 
UIView.animateWithDuration(1) {() -> Void in 
    animatedBackroundColorView.frame = tableView.frame 
} 
XCPShowView("identifier", view: tableView) 

人丁:enter image description here

+0

请不要添加代码片段 – Nitish

+0

我加了片段:) – Antzi

1

试试这个

UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(cell.frame.size.width + 1,0,cell.frame.size.width,cell.frame.size.height)]; 
[backgroundView setBackgroundColor:yourColor]; 
[cell addSubview:backgroundView]; 
[UIView animateWithDuration:2.0 animations:^{ 
    CGRect rect = backgroundView.frame; 
    rect.origin.x = 0; 
    [backgroundView setFrame:rect]; 
} completion:NULL]; 
+0

这不是OP所要求的(从右到左填充背景颜色)。 – Antzi