在swift中隐藏UIView动画



我试图用动画隐藏/呈现UITextField。动画工作时,呈现文本字段,但不隐藏时,有什么特别的原因吗?

UIView.transition(with: self.confirmPasswordTextField, duration: 0.5, options: [.transitionCrossDissolve], animations: {
self.confirmPasswordTextField.isHidden = self.login
self.layoutIfNeeded()
})

您最好使用alpha

self.confirmPasswordTextField.alpha = show ? 0.0 : 1.0
UIView.transition(with: self.confirmPasswordTextField, duration: 0.5, options: [.transitionCrossDissolve], animations: {
self.confirmPasswordTextField.alpha = show ? 1.0 : 0.0
})

相关内容

  • 没有找到相关文章

最新更新