I am usig the default tableview cell focus animation.
Default focus colour is white.
How can we change the focus colour if we want to use the default tableview cell animation?
I am usig the default tableview cell focus animation.
Default focus colour is white.
How can we change the focus colour if we want to use the default tableview cell animation?
You can accomplish what you want by setting the background color of the cell's `contentView` during the `willDisplayCell` delegate method. For example:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.contentView.backgroundColor = [UIColor redColor];
}
Subclass UITableViewCell and do something like this:
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
super.didUpdateFocusInContext(context, withAnimationCoordinator: coordinator)
if context.nextFocusedView === self {
coordinator.addCoordinatedAnimations({
self.contentView.backgroundColor = UIColor.darkGrayColor()
}, completion: nil)
}
else {
coordinator.addCoordinatedAnimations({
self.contentView.backgroundColor = UIColor.blackColor()
}, completion: nil)
}
}