JoniVR / VerticalCardSwiper

A marriage between the Shazam Discover UI and Tinder, built with UICollectionView in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strange behaviour of CardCell layout

Lavmint opened this issue · comments

New Issue Checklist

Issue Description

Steps to reproduce:

  1. Create UIViewController and add UILabel inside of it, stretch label to edges with constraints
  2. Add VC's view as subview to CardView, stretch VC's view to edges of CardView with constraints
  3. Run app and try to scroll, it seems that glitch depends on size of text

output

Environment

  • iOS Version: iOS 12.1
  • Device(s): iPhone 5S Simulator
  • Xcode Version: 10.1 (10B61)

Hi @Lavmint

This is (most probably) due to the firstItemTransform property of the custom flowlayout.

Because the card resizes (transforms) once it gets pushed to the background, the contents of the card need to be resized too (this happens at every bounds change, see the shouldInvalidateLayout function inside VerticalCardSwiperFlowLayout.swift).

So everything is actually working as intended (including the constraints).

Possible solutions:

  • The first obvious solution would be to set the firstItemTransform property of the VerticalCardSwiper to 0. Although you would lose the effect by doing that.
  • You can also try playing around with the constraints, setting <= or >= value on leading and trailing edges and giving a width to the UILabel or something along those lines.
    You might also want to look into content hugging and compression resistance priorities.

Hope this helps. 😄

I'll be closing this for now as it's intended behaviour.
Feel free to reopen if you have feedback, questions or remarks. 🙂

Best regards
Joni