Step 1
In the cellForRowAtIndexPath method where your cell is initialized, hide it;
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell: TblCell = tableView.dequeueReusableCell(withIdentifier: "cell") as! TblCell cell.continueLabel.textAlignment = .justified cell.contentView.alpha = 0 return cell }
Step 2
Let it do a fade animation. UITableViewDelegate has a willDisplayCell method which can detect that when scrolling up or down, the first cell will be displayed in the window.
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { UIView.animate(withDuration: 0.8, animations: { cell.contentView.alpha = 1 }) }
Your fade animation is about progress. Most importantly, you cannot customize your alpha cell directly at runtime, because iOS does some special internal processing with the cell as part of your UITableView and ignores your setting. Therefore, if you customize your contentView , everything will be fine.
Kemal can kaynak
source share