Autolayout is not resizing Uicollectionviewcell items when animating between layouts

旧巷老猫 提交于 2019-12-21 06:36:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!