Sometimes you feel the need that the NSView that you are working with  resizing, moving, etc. feels too rude when you change the position, the dimensions or anything.

A code snipped that could help you out giving a little ease is the follow:

NSAnimationContext.RunAnimation (
(context) => {
	context.Duration = 0.5;
	context.AllowsImplicitAnimation = true;
			}, null);

The NSAnimationContext.RunAnimation has two properties of type actions that will help you out with the basic:

  1. The changes action: This is where you would put the code that will transform your view as you can see you have a parameter (I called mine context) which have severals properties for you to play with, for example I use Duration to declare that my animation should take 0.5 seconds to happen and I set AllowsImplicitAnimation equals true, this tells that whatever happen in the changes action should be animated.
  2. the completion action: You can define what should happen when the animation ends. Is not mandatory I put mine as null because I don’t need to do something here.

Quick and easy. I put this snipped here because when I was googling about it wasn’t easy to find, in manner of facts, I didn’t find anything concrete but found.

pd: I don’t say is the best way, because I haven’t go too deep in the subject, but It does the trick pretty well

Hope it help anyone googling arround 🙂

Starlin González
Latest posts by Starlin González (see all)