Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift——当删除UIView(动画)时,它将保持在屏幕上_Ios_Swift_Uiview_Uiviewanimation_Uiviewanimationtransition - Fatal编程技术网

Ios Swift——当删除UIView(动画)时,它将保持在屏幕上

Ios Swift——当删除UIView(动画)时,它将保持在屏幕上,ios,swift,uiview,uiviewanimation,uiviewanimationtransition,Ios,Swift,Uiview,Uiviewanimation,Uiviewanimationtransition,我有以下Swift代码。问题是,当它被执行时,它会执行动画,但窗口仍保持在原始位置,如所附的gif I所示 UIView.animateKeyframes(withDuration: 0.5, delay: 0, options: .calculationModePaced, animations: { self.view.viewWithTag(123)?.frame = CGRect(x: screenWidth5/2, y: screenHeight, width: screenW

我有以下Swift代码。问题是,当它被执行时,它会执行动画,但窗口仍保持在原始位置,如所附的gif I所示

UIView.animateKeyframes(withDuration: 0.5, delay: 0, options: .calculationModePaced, animations: {
    self.view.viewWithTag(123)?.frame = CGRect(x: screenWidth5/2, y: screenHeight, width: screenWidth5 * 4, height: screenHeight5 * 3 )
}, completion: .none)

self.view.viewWithTag(123)?.removeFromSuperview()

感谢您的时间和回答。

您需要将
removeFromSuperview
放入完成处理程序中

UIView.animateKeyframes(withDuration: 0.5, delay: 0, options: .calculationModePaced, animations: {
    self.view.viewWithTag(123)?.frame = CGRect(x: screenWidth5/2, y: screenHeight, width: screenWidth5 * 4, height: screenHeight5 * 3 )
}) { _ in
    self.view.viewWithTag(123)?.removeFromSuperview()
}