Ios 背景图像导致动画popViewController延迟/滞后
当弹出视图控制器时,我会延迟动画 我得到延迟的原因是因为我有背景图像Ios 背景图像导致动画popViewController延迟/滞后,ios,swift,viewcontroller,Ios,Swift,Viewcontroller,当弹出视图控制器时,我会延迟动画 我得到延迟的原因是因为我有背景图像 override func viewDidLoad() { super.viewDidLoad() setBackgroundImage() } @IBAction func navigationButton(_ sender: Any) { print("navigation button presssed
override func viewDidLoad() {
super.viewDidLoad()
setBackgroundImage()
}
@IBAction func navigationButton(_ sender: Any) {
print("navigation button presssed")
self.navigationController?.popViewController(animated: true)
}
func setBackgroundImage() {
let backgroundImage = UIImageView(frame: UIScreen.main.bounds)
backgroundImage.image = UIImage(named: "RewardsBackgroundONLY")
backgroundImage.contentMode = UIView.ContentMode.scaleAspectFill
self.view.insertSubview(backgroundImage, at: 0)
}
如何在设置背景图像时防止发生延迟
override func viewDidLoad() {
super.viewDidLoad()
setBackgroundImage()
}
@IBAction func navigationButton(_ sender: Any) {
print("navigation button presssed")
self.navigationController?.popViewController(animated: true)
}
func setBackgroundImage() {
let backgroundImage = UIImageView(frame: UIScreen.main.bounds)
backgroundImage.image = UIImage(named: "RewardsBackgroundONLY")
backgroundImage.contentMode = UIView.ContentMode.scaleAspectFill
self.view.insertSubview(backgroundImage, at: 0)
}
我还尝试在主线程上弹出视图控制器,但仍然不起作用。可能是您的图像太大,而内容模式
backgroundImage.contentMode=UIView.contentMode.scaleAspectFill
导致了此行为
解决这个问题有两种方法
scaleToFill
或scaleSpectFit
可能您的图像太大,而内容模式
backgroundImage.contentMode=UIView.contentMode.scaleAspectFill
导致此行为
解决这个问题有两种方法
scaleToFill
或scaleSpectFit
奇怪的是,我从来没有
scaleAspectFill
lag我的app@aheze事实上,这并没有造成滞后,但似乎是一种滞后。这是导航中的奇怪行为controller@RamiresNascimento明白了,奇怪。奇怪的是,我从未有过scaleSpectFill
滞后app@aheze事实上,这并没有造成滞后,但似乎是一种滞后。这是导航中的奇怪行为controller@RamiresNascimento明白了,奇怪。