2016-03-10 103 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