我试图在UIView出现在屏幕上时使用动画过渡。 UIView正确显示,但是动画在出现时不会发生。UIView过渡动画没有执行
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let coreView = UIView(frame: CGRect(x: 10, y: 10, width: 100, height: 100))
coreView.backgroundColor = UIColor.cyan
coreView.layer.borderColor = UIColor.darkGray.cgColor
coreView.layer.borderWidth = 8
coreView.layer.cornerRadius = 15
coreView.isHidden = true
self.view.addSubview(coreView)
//The transition occurs here
UIView.transition(with: coreView, duration: 2, options: [.curveEaseInOut, .transitionCurlDown], animations: {
coreView.isHidden = false
}, completion: {_ in})
}
就这样做了!它现在工作:) – SwiftyJD