Strange behaviour of CardCell layout
Lavmint opened this issue · comments
New Issue Checklist
- I updated VerticalCardSwiper to the latest version.
- I read the Contribution Guidelines.
- I read the documentation.
- I searched for existing GitHub issues.
Issue Description
Steps to reproduce:
- Create
UIViewController
and addUILabel
inside of it, stretch label to edges with constraints - Add VC's
view
as subview toCardView
, stretch VC'sview
to edges ofCardView
with constraints - Run app and try to scroll, it seems that glitch depends on size of text
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 theVerticalCardSwiper
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