Reputation: 14113
Starting from the right end, I have to fill the color in UITableViewCell
(or to say it better, change the background of UITableViewCell
starting from right to left in a small duration). How may I achieve this ?
Upvotes: 1
Views: 669
Reputation: 13424
It's quite easy.
Just put a view in the background, starting with a 0 width and on the right of the tableview/tableview cell, then animate it to the full width of the superview.
Code snippet (in form of a Swift playground)
import UIKit import 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)
Upvotes: 4
Reputation: 1324
try this
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];
Upvotes: 1