Skip to content

Commit 4a1d95c

Browse files
author
Michele Volpato
committed
Transition source and target consider safe area.
Fixes #10
1 parent f16c738 commit 4a1d95c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Examples/NavigationTransitionsExample/Transition/Transition/InteractiveZoomTransitionController.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,23 @@ extension InteractiveZoomTransitionController : SharedElementProvider {
6666

6767
let initialFrame: CGRect
6868
let targetFrame: CGRect
69+
70+
// Get top margin, depending on possible safe area
71+
var yMargin: CGFloat
72+
73+
if #available(iOS 11.0, *) {
74+
yMargin = toViewController.collectionView.safeAreaInsets.top
75+
} else {
76+
yMargin = 0.0
77+
}
78+
79+
yMargin += CollectionViewController.margin
6980

7081
if isPresenting {
7182
initialFrame = fromViewController.targetFrame
72-
targetFrame = CGRect(origin: CGPoint(x: CollectionViewController.margin, y: CollectionViewController.margin), size: header.image.frame.size)
83+
targetFrame = CGRect(origin: CGPoint(x: CollectionViewController.margin, y: yMargin), size: header.image.frame.size)
7384
} else {
74-
initialFrame = CGRect(origin: CGPoint(x: CollectionViewController.margin, y: CollectionViewController.margin), size: header.image.frame.size)
85+
initialFrame = CGRect(origin: CGPoint(x: CollectionViewController.margin, y: yMargin), size: header.image.frame.size)
7586
targetFrame = toViewController.targetFrame
7687
}
7788

0 commit comments

Comments
 (0)