CocoaDev

Edit AllPages

Today, I discovered the magic of NSViewAnimation. But I found it rather awkward to use on a quick basis, so I cooked up a lovely category on NSView that allows you to send it messages like fadeOut and animateToFrame in about 1/10th the characters. Sensible defaults are provided for everything, but you can change them if necessary. MIT License.

NSView+AMAnimationAdditions.h

// // NSView+AMAnimationAdditions.h // MovingView // // Created by Andy Matuschak on 11/6/05. // Copyright 2005 Andy Matuschak. All rights reserved. //

#import <Cocoa/Cocoa.h>

@interface NSView (AMAnimationAdditions)

NSView+AMAnimationAdditions.m

// // NSView+AMAnimationAdditions.m // MovingView // // Created by Andy Matuschak on 11/6/05. // Copyright 2005 Andy Matuschak. All rights reserved. //

#import “NSView+AMAnimationAdditions.h”

NSTimeInterval AMDefaultAnimationDuration = -1; // -1 makes the system provide a default duration NSAnimationBlockingMode AMDefaultAnimationBlockingMode = NSAnimationNonblocking; NSAnimationCurve AMDefaultAnimationCurve = NSAnimationEaseInOut;

@implementation NSView (AMAnimationAdditions)

@end

Requires 10.4, of course. I hope these things prove useful. Please let me know if there are problems or suggestions.

– AndyMatuschak

Category:CocoaDevUsersAdditions