I'm trying to see if I can make insertions/deletions in an NSStackView a little 
more animated. So I did the simplest thing I could think of, wrapped the 
insert/delete in an NSAnimationContext, made the control layer-backed, turned 
on implicit animations and called layoutSubviewsIfNeeded. Something like this

stackView.wantsLayer = YES;
 ...
[ NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
        context.duration = somethingVeryLong;
        context.allowsImplicitAnimation = YES;  
        
        [ stackView insertView:aNewView atIndex:aNewIndex ];
        [ stackView layoutSubviewsIfNeeded ];   // doesn't appear to be needed, 
also tried [ stackView.window layoutIfNeeded ]
}
completionHandler:NULL ];

I figured that the new incoming view would be problematic, but I expected that 
the existing views would at least animate from their current positions to their 
final positions smoothly because the layoutSubviewIfNeeded would end up setting 
their frames inside the animation block and they would animate from their 
current positions to there. So I expected the views above the insertion point 
would stay still, and those below would move down and the incoming view would 
appear in some way I wasn't that concerned about at this point.  However what 
actually happens is the opposite; ALL the views in the stack jump down 
instantly leaving a view-sized gap at the very top  and then the ones above the 
insertion point animate back up to their original positions again.

I think I'm on a road to nowhere trying to make stackview animate in this 
simplistic a fashion, it was worth a try and I didn't expect it would really 
work. However I can't understand this particular behaviour, all the changes are 
being made inside an animation block with a layout at the end, so I don't see 
how the views 'jump' before they animate back. Any theories? 
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to