[英]animation not correct with implicit autolayout
I upload my demo code here: https://github.com/liuxuan30/Problems 我在此处上传演示代码: https : //github.com/liuxuan30/Problems
The main problem is, I had a view which have a scroll view inside, and there is a label and collection view inside scroll view. 主要问题是,我有一个内部带有滚动视图的视图,并且在滚动视图内部有一个标签和集合视图。
There will be a unread message button generated by code, when there is unread messages, the button will pop out, and I expect the animation: label and collection view will down-shift by the button's height. 代码将产生一个未读消息按钮,当有未读消息时,该按钮将弹出,并且我希望动画:标签和集合视图将按按钮的高度向下移动。
When I test the animation without adding the button in subviews, animate as expected. 当我测试动画而不在子视图中添加按钮时,请按预期进行动画处理。
When I add the button in, it seems like the label and collection view's origin.Y up-shifted, and start the animation. 当我添加按钮时,好像标签和集合视图的原点。Y向上移动,然后开始动画。 Turning off auto layout will solve it, but I have to have auto layout. 关闭自动布局将解决该问题,但是我必须具有自动布局。 I tried to add constraints for all views, but the animation still not work out. 我尝试为所有视图添加约束,但是动画仍然无法解决。
You can try comment out [self.HomeScrollView addSubview:AlertView];
您可以尝试注释掉[self.HomeScrollView addSubview:AlertView];
and self.UnreadAlertView.alpha = 1.0f;
和self.UnreadAlertView.alpha = 1.0f;
inside the code to see the animation. 在代码中查看动画。
Hope someone could figure out where i did wrong. 希望有人能弄清楚我做错了什么。
UICollectionView
is already a subclass of UIScrollView
. UICollectionView
已经是UIScrollView
的子类。 Embedding your collection view inside a scroll view may be what is causing problems with your animation. 将集合视图嵌入滚动视图中可能是导致动画出现问题的原因。
Try removing your scroll view and just put your UIButton
, UILabel
, and UICollectionView
inside your overarching view. 尝试删除滚动视图,然后将UIButton
, UILabel
和UICollectionView
放在总体视图中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.