tableviewCell呈现动画
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
// cell.alpha = 0
// UIView.animate(withDuration: 1.0) {
// cell.alpha = 1
// }
let rotationAngleInRadians = 30.0 * CGFloat(Double.pi / 180.0)
let rotationTransform = CATransform3DMakeRotation(rotationAngleInRadians, 0, 0, 1)
cell.layer.transform = rotationTransform
UIView.animate(withDuration: 1.0) {
cell.layer.transform = CATransform3DIdentity
}
}
中CATransform3DMakeRotation函数有四个参数,其中弧度(radian)表示的角度,这是旋转角度,因为角度以弧度来表示,所以需要先将degree转为弧度