From f9dd65de40d9e536ef9339e4dd1161dfc8c6530b Mon Sep 17 00:00:00 2001 From: nakajijapan Date: Wed, 28 Jul 2021 14:15:11 +0900 Subject: [PATCH] invalid animation --- PhotoSliderDemo/ViewController.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PhotoSliderDemo/ViewController.swift b/PhotoSliderDemo/ViewController.swift index 98d9a78..64ee119 100644 --- a/PhotoSliderDemo/ViewController.swift +++ b/PhotoSliderDemo/ViewController.swift @@ -225,7 +225,7 @@ extension ViewController: ZoomingAnimationControllerTransitioning { let imageView = UIImageView(image: cell.imageView.image) var frame = cell.imageView.frame - frame.origin.y += UIApplication.shared.statusBarFrame.height + frame.origin.y += view.window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0 // tune in UIImageView frame.origin.x = view.safeAreaInsets.left if view.bounds.width > view.bounds.height { @@ -248,17 +248,17 @@ extension ViewController: ZoomingAnimationControllerTransitioning { guard let cell = collectionView.visibleCells.first as? ImageCollectionViewCell else { return } - let statusBarHeight: CGFloat = UIApplication.shared.statusBarFrame.height + let statusBarHeight: CGFloat = view.window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0 + let topPosition: CGFloat = view.safeAreaLayoutGuide.layoutFrame.origin.y var frame = CGRect.zero if view.bounds.size.width < view.bounds.height { - if image.size.height < image.size.width { let width = (sourceImageView.image!.size.width * sourceImageView.bounds.size.width) / sourceImageView.image!.size.height let x = (width - cell.imageView.bounds.height) * 0.5 - frame = CGRect(x: -1.0 * x, y: statusBarHeight, width: width, height: cell.imageView.bounds.height) + frame = CGRect(x: -1.0 * x, y: topPosition, width: width, height: cell.imageView.bounds.height) } else { - frame = CGRect(x: 0.0, y: statusBarHeight, width: view.bounds.width, height: view.bounds.width) + frame = CGRect(x: 0.0, y: topPosition, width: view.bounds.width, height: view.bounds.width) } } else {