Ios Swift——当删除UIView(动画)时,它将保持在屏幕上
我有以下Swift代码。问题是,当它被执行时,它会执行动画,但窗口仍保持在原始位置,如所附的gif I所示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
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()
}