FlippingNotch
FlippingNotch is "pull to refresh/add/show" custom animation written Swift, using the iPhone X Notch.
What FlippingNotch is not
It is not a framework, it is just an Xcode project, embracing the notch.
Requirements
FlippingNotch is written in Swift 4.0 and requires an iPhone X Simulator/Device.
Tutorial
- Put a UICollectionView and constraint it in a ViewController.
The image below shows an example how to constraint it.

- Add a cell in the UICollectionView.

- Set up the UICollectionView in the ViewController by conforming to UICollectionViewDataSource.
- The Notch View
- Instantiate a view that represents the notch. The
notchViewBottomConstraint
is used to position the notchView into the view.
- After instantiating the notchView, add it as a subview its parent view.
The notchView have a black background and rounded corners.
translatesAutoResizingMaskIntoConstraints
needs to be set tofalse
because we want to use auto layout for this view rather than frame-based layout.
Then, the notchView is constrained to the center of its parent view, with the same width as the notch, a height of(notch height - maximum scrolling offset what we want to give)
and a bottom constrained to its parent viewtopAnchor
+ notch height.
The result in an iPhone 8:

- Reacting while scrolling
(Looks clearer in an iPhone 8 what we are trying to do)
-
We want to move down the notchView while scrolling
-
To do this, first we have to conform our ViewController to UICollectionViewDelegate and call
scrollViewDidScroll
delegate function. In there we write the logic to move the notchView down. -
The scrollView should scroll until it reaches
the maximum scrolling offset what we want to give
-
The bottom constrained of the notchView should be increased while scrolling.
- Drop the view from the notch
-
When the scroll did end dragging we want to create the view that will be part of the flipping animation.
-
We create the animatableView, reset
notchBottomConstraint
, and move down thecollectionView
and drop the animatableView (notchView clone) with an animation and we round its corners.
- Flip it
- After dropping the view, a snapshot of the
collectionview cell
is taken, the image is set on theanimatableView
and it is flipped with an animation.

Limitations
The animation works as expected only in iPhone X in portrait mode
TODO
- Include the case when a NavigationBar is implemented.