TableViewCell animation in swift

后端 未结 6 662
囚心锁ツ
囚心锁ツ 2021-02-04 15:54

I am following THIS tutorial and achieve that animation with this code:

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtInd         


        
6条回答
  •  忘了有多久
    2021-02-04 16:51

    Use this code to get spiral cells animation in your tableview

    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        //1. Setup the CATransform3D structure
       var rotation = CATransform3DMakeRotation( CGFloat((90.0 * M_PI)/180), 0.0, 0.7, 0.4);
        rotation.m34 = 1.0 / -600
    
        //2. Define the initial state (Before the animation)
        cell.layer.shadowOffset = CGSize(width: 10.0, height: 10.0)
        cell.alpha = 0;
        cell.layer.transform = rotation;
        cell.layer.anchorPoint = CGPoint(x: 0.0, y: 0.5)
    
        //3. Define the final state (After the animation) and commit the animation
        cell.layer.transform = rotation
        UIView.animate(withDuration: 0.8, animations:{cell.layer.transform = CATransform3DIdentity})
        cell.alpha = 1
        cell.layer.shadowOffset = CGSize(width: 0, height: 0)
        UIView.commitAnimations()
    }
    

提交回复
热议问题