Uiview 如何制作重复与连续动画?

Uiview 如何制作重复与连续动画?,uiview,uianimation,Uiview,Uianimation,场景:我有一个“>”按钮: 在初次点击时应设置+90度的动画: 但是,再次点击UITableViewCell返回到0度'>'位置后,返回到其原始高度;然后再次点击,我将进一步旋转到“”,我需要在以后点击旋转图标之前重置“>”图像的变换根据马特的建议,我通过将其转换设置为“身份”实现了这一点 func rotateImageView() { // Reset any pending transformation to original status: rig

场景:我有一个“>”按钮:

在初次点击时应设置+90度的动画:


但是,再次点击UITableViewCell返回到0度'>'位置后,返回到其原始高度;然后再次点击,我将进一步旋转到“”,我需要在以后点击旋转图标之前重置“>”图像的变换
根据马特的建议,我通过将其转换设置为“身份”实现了这一点

 func rotateImageView() {
        // Reset any pending transformation to original status:
        rightArrowImage.transform = .identity

        UIView.animate(withDuration: 0.3) {
            self.rightArrowImage.transform = self.rightArrowImage.transform.rotated(by: .pi / 2)
        }
    }
这是通过UITableViewDelete的willDisplay函数触发的:

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        let myCell = cell as? CommonFAQCell
        if expandCell {
            myCell?.rotateImageView()
        }
    }

“但是,在返回到0度'>'位置后”请显示执行此操作的代码。它应该包括将
转换设置为
.identity
。我没有代码。我只需再次点击,UITableViewCell的高度就会恢复到其原始大小。。。。。“>”图标将返回其原始状态。您没有显示关于点击或更改单元格高度的代码。但你只是暗示它存在。所以你有代码。给我看看,你给了我暗示。我解决了它!
 func rotateImageView() {
        // Reset any pending transformation to original status:
        rightArrowImage.transform = .identity

        UIView.animate(withDuration: 0.3) {
            self.rightArrowImage.transform = self.rightArrowImage.transform.rotated(by: .pi / 2)
        }
    }
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        let myCell = cell as? CommonFAQCell
        if expandCell {
            myCell?.rotateImageView()
        }
    }