Unexpected animation from UICalendarView embedded in UIStackView

I have a UICalendarView that is embedded in a UIStackView. When I hide/show items in the stack and cause the height of the stack to change, the UICalendarView animates unexpectedly:

Note that the height and width of the UICalendarView remain unchanged and the animation appears to leave the actual content unchanged.

Interestingly, if I select a month with 6 weeks it does not do this animation:

Nothing I have tried has allowed me to avoid this distracting and unnecessary animation. Any thoughts as to why this is happening or, even better, is there anything I can do to avoid it?

Appreciate the help!

Answered by giggybank in 799622022

After a bit of experimentation, I found out that the animation happens when I assign the UICalendarView's selectionBehavior property to an instance of UICalendarSelectionMultiDate (to enable multiple date selection) just before animating the changes to the UIStackView's contents. I'm not sure why that triggers an animation but I was at least able to fix my specific issue by simply assigning the new selectionBehavior in the completion block of my animation.

Accepted Answer

After a bit of experimentation, I found out that the animation happens when I assign the UICalendarView's selectionBehavior property to an instance of UICalendarSelectionMultiDate (to enable multiple date selection) just before animating the changes to the UIStackView's contents. I'm not sure why that triggers an animation but I was at least able to fix my specific issue by simply assigning the new selectionBehavior in the completion block of my animation.

Unexpected animation from UICalendarView embedded in UIStackView
 
 
Q