Reputation: 740
I am using a collectionView with FlowLayout. Please find the following image.
In the image, the white area is the collectionView. During Runtime the red color view might get hidden based on a condition. So the collectionView will have to move up. That is not an issue. That works as expected. But when the collectionView moves up, the 'All Months' button which is connected to collectionView by vertical spacing constraint of 20 pixels does not move up.
My requirement is that the 'All Months' button has to be 20 pixels next to the collectionView even if the collectionView changes its y position or height during runtime.
EDIT: I have moved the contentView of my ScrollView upwards to show you the constraints of 'All Months' and 'Next' buttons. Pl check the following images
Upvotes: 2
Views: 672
Reputation: 1423
I am changing the whole answer after looking and editing your project, here you go with the edited link which i forked from your project:
https://github.com/subhajitregor/AutoLayoutTest
The thing I have Changed:
Content View inside your scrollview its height constraints priority is changed to 250(low priority) as it was not getting shorter if your orange view gets hidden.
In your viewWillAppear()
I added self.view.layoutIfNeeded()
and commented out the inner code of viewDidLayoutSubviews()
(you can reopen the code as your needs)
I have checked it and its working as needed. Please do check that project in the link I provided and let me know.
Upvotes: 3