Mac Developer Library

Developer

AppKit Framework Reference NSViewAnimation Class Reference

Options
Deployment Target:

On This Page
Language:

NSViewAnimation

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.4 and later.

The NSViewAnimation class, a public subclass of NSAnimation, offers a convenient way to animate multiple views and windows. The animation effects you can achieve are limited to changes in frame location and size, and to fade-in and fade-out effects.

An NSViewAnimation object takes an array of dictionaries from which it determines the objects to animate and the effects to apply to them. Each dictionary must have a target object and, optionally, properties that specify beginning and ending frame and whether to fade in or fade out. (See View Animation Dictionary Keys for further information.) Animations with NSViewAnimation are, by default, in non-blocking mode over a duration of 0.5 seconds using the ease in-out animation curve. But you can configure the animation to have any duration, curve, frame rate, and blocking mode. You may also set progress marks, assign a delegate, and implement delegation methods in order to animate view and windows concurrent with the ones specified as targets in the view-animation dictionary.

Invoking the NSAnimation stopAnimation method on a running NSViewAnimation object moves the animation to the end frame.

  • Returns an NSViewAnimation object initialized with the supplied information.

    Declaration

    Swift

    init(viewAnimations viewAnimations: [AnyObject])

    Objective-C

    - (instancetype)initWithViewAnimations:(NSArray *)viewAnimations

    Parameters

    viewAnimations

    An array of NSDictionary objects. Each dictionary specifies a view or window to animate and the effect to apply. viewAnimations can be nil, but you must later set the required array of dictionaries with setViewAnimations: if you want to use the capabilities of the NSViewAnimation class. SeeView Animation Dictionary Keys for a description of valid keys and values for dictionaries in viewAnimations.

    Return Value

    The created NSViewAnimation object or nil if there was a problem initializing the object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Sets the dictionaries defining the objects to animate.

    Declaration

    Swift

    var viewAnimations: [AnyObject]?

    Objective-C

    @property(copy) NSArray *viewAnimations

    Parameters

    viewAnimations

    An array of NSDictionary objects. Each dictionary specifies a view or window to animate and the effect to apply. Pass in nil to remove the current list of dictionaries. See View Animation Dictionary Keys for a description of valid keys and values for dictionaries in viewAnimations.

    Discussion

    If you call this method while an animation is in-flight, the animation will execute stopAnimation and then reset the view animations. Those view animations will take effect the next time the animation is started.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the array of dictionaries defining the objects to animate.

    Declaration

    Swift

    var viewAnimations: [AnyObject]?

    Objective-C

    @property(copy) NSArray *viewAnimations

    Discussion

    Each dictionary in the returned array specifies a view or window to animate and the effect to apply.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The following string constants are keys for the dictionaries in the array passed into initWithViewAnimations: and setViewAnimations:.

    Declaration

    Swift

    let NSViewAnimationTargetKey: String let NSViewAnimationStartFrameKey: String let NSViewAnimationEndFrameKey: String let NSViewAnimationEffectKey: String

    Objective-C

    NSString *NSViewAnimationTargetKey; NSString *NSViewAnimationStartFrameKey; NSString *NSViewAnimationEndFrameKey; NSString *NSViewAnimationEffectKey;

    Constants

    • NSViewAnimationTargetKey

      NSViewAnimationTargetKey

      The target of the animation.

      The target can be either an NSView object or an NSWindow object. This property is required.

      Available in OS X v10.4 and later.

    • NSViewAnimationStartFrameKey

      NSViewAnimationStartFrameKey

      The size and location of the window or view at the start of the animation.

      The size and location are specified by an NSRect structure encoded in an NSValue object. This property is optional. If it is not specified, NSViewAnimation uses the frame of the window or view at the start of the animation.

      Available in OS X v10.4 and later.

    • NSViewAnimationEndFrameKey

      NSViewAnimationEndFrameKey

      The size and location of the window or view at the end of the animation.

      The size and location are specified by an NSRect structure encoded in an NSValue object. This property is optional. If it is not specified, NSViewAnimation uses the frame of the window or view at the start of the animation. If the target is a view and the end frame is empty, the view is hidden at the end.

      Available in OS X v10.4 and later.

    • NSViewAnimationEffectKey

      NSViewAnimationEffectKey

      An effect to apply to the animation.

      Takes a string constant specifying fade-in or fade-out effects for the target: NSViewAnimationFadeInEffect and NSViewAnimationFadeOutEffect. If the target is a view and the effect is to fade out, the view is hidden at the end. If the effect is to fade in an initially hidden view and the end frame is non-empty, the view is unhidden at the end. If the target is a window, the window is ordered in or out as appropriate to the effect. This property is optional.

      Available in OS X v10.4 and later.

  • The following constants specify the animation effect to apply and are used as values for the animation effect property of the animation view. See the description of NSViewAnimationEffectKey for usage details.

    Declaration

    Swift

    let NSViewAnimationFadeInEffect: String let NSViewAnimationFadeOutEffect: String

    Objective-C

    NSString *NSViewAnimationFadeInEffect; NSString *NSViewAnimationFadeOutEffect;

    Constants

    • NSViewAnimationFadeInEffect

      NSViewAnimationFadeInEffect

      Specifies a fade-in type of effect.

      Available in OS X v10.4 and later.

    • NSViewAnimationFadeOutEffect

      NSViewAnimationFadeOutEffect

      Specifies a fade-out type of effect.

      Available in OS X v10.4 and later.