christmas sale

Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10

Grab It Now
Check Mobile App
Read now
Start a Project

Flipping Notch

Save

What Flipping Notch

Flipping Notch is not a framework, it is just an Xcode project, embracing the notch.

1. Put a UICollectionView and constraint it in a ViewController.

The image below shows an example how to constraint it.

2. Add a cell in the UICollectionView.

3. Set up the UICollectionView in the ViewController by conforming to UICollectionViewDataSource.

4. 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 to false 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 view topAnchor + notch height.

The result in an iPhone 8:

 

5. Reacting while scrolling

(Looks clearer in an iPhone 8 what we are trying to do)

  • 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 will increase while scrolling.

6. 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 the collectionView and drop the animatableView (notchView clone) with an animation and we round its corners.

7. Flip it

  • After dropping the view, a snapshot of the collectionview cell is taken, the image is set on the animatableView and it is flipped with an animation.

Limitations

The animation works as expected only in iPhone X in portrait mode

TODO

  •  when you implement a NavigationBar please include the case.

For more Blogs please click here

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home