简体   繁体   中英

animation not correct with implicit autolayout

I upload my demo code here: 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. 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]; and 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 . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM