问题
I have a uicollectionview cell with an image view inside that I want to resize when I switch to a larger 'zoomed in' layout.
I have placed constraints inside the cell that does resize the image view when the zoomed in layout is displayed. I am using uicollectionview setLayout animated method.
The problem is the image does not scale with animation only the collection view cell does.
The image seems to just jump into its end size with no interpolation. So the animation looks extremely choppy.
It seems as if I need to somehow control the auto layout constraints so they animate with the set layout animated method but I don't know how.
Is there a proper way to scale the cell and it's contents ?
Thanks so much!
回答1:
I had (have) the same problem with Auto Layout!
Presently the simplest way I've found to deal with it is to set:
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
This causes the imageView size transition to be animated smoothly and is the only thing that I've found to work consistently with setCollectionViewLayout:animated:
回答2:
You may find this answer and the linked GitHub demo app I wrote to solve a similar issue helpful.
来源:https://stackoverflow.com/questions/20837491/autolayout-is-not-resizing-uicollectionviewcell-items-when-animating-between-lay