0

I am writing an interactive transition via UIViewControllerAnimatedTransitioning. As part of the transition, I apply a CGAffineTransform to the from view controller.

As soon as the transform is applied, fromViewController loses its safeAreaInset at the top. This looks jarring.

Here is a pic just before the transition starts. Normal status bar, navigation bar, and safe area insets (top). Around 88 points high. Standard status bar and nav bar

This is the first frame of the transition. Notice that the top spacing is now more like 44 points. enter image description here

The fromVC remains this way all the way through the transition. I have tried different ways of applying the transforms, but they all behave the same way. I have also removed the rounded corners.

Here are the transforms:

var transform = CGAffineTransform.identity
            transform.concatenating(CGAffineTransform.identity.translatedBy(x: 0, y: yInset / 2))
            transform.concatenating(CGAffineTransform.identity.scaledBy(x: scaleX, y: scaleY))

fromVC.view.transform = transform
VaporwareWolf
  • 10,143
  • 10
  • 54
  • 80

1 Answers1

0

The way I ended up solving this was to use CATransform3D instead of CGAffineTransform. The padding remains in place with this technique.

let scale = CATransform3DScale(CATransform3DIdentity, scaleX, scaleY, 1)
let translate = CATransform3DTranslate(scale, 0, yInset / 2, 0)
return CATransform3DConcat(scale, translate)

enter image description here

VaporwareWolf
  • 10,143
  • 10
  • 54
  • 80