• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: The simplest way to fade out a view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The simplest way to fade out a view


  • Subject: Re: The simplest way to fade out a view
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 19 May 2011 15:18:03 -0700

On May 19, 2011, at 15:01, Nick wrote:

> No, only fade out (and fade in) effects are needed. I just added frame
> movement to see if animation works at all. Animation does work, but
> the fade does not happen - no matter, if the frame is moved
> simultaneously or not.

Here's my actual code for doing this. It works.

> 	NSMutableArray* dictionaries = [NSMutableArray array];
>
> 	//	Create a dictionary for the animation parameters
>
> 	NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithObject: subview forKey: NSViewAnimationTargetKey];
> 	[dictionaries addObject: dictionary];
>
> 	//	Add a key for the target frame rect, if necessary
>
> 	if (!shouldBeHidden || !NSEqualRects (oldFrameRect, newFrameRect))
> 		[dictionary setObject: [NSValue valueWithRect: newFrameRect] forKey: NSViewAnimationEndFrameKey];
>
> 	//	If the visibility is changing, add a key for the fade in or out
>
> 	if (!isHidden != !shouldBeHidden)
> 	{
> 		[dictionary setObject: shouldBeHidden ? NSViewAnimationFadeOutEffect : NSViewAnimationFadeInEffect forKey: NSViewAnimationEffectKey];
>
> 		//	Work around a Snow Leopard bug ...
>
> 		if (!shouldBeHidden)
> 			[subview setHidden: shouldBeHidden];
> 	}
>
> 	//	Create the animation
>
> 	NSViewAnimation* viewAnimation = [[NSViewAnimation alloc] initWithViewAnimations: dictionaries];
>
> 	viewAnimation.duration = 0.25;
> 	viewAnimation.animationCurve = NSAnimationEaseIn;
>
> 	[viewAnimation startAnimation];
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: The simplest way to fade out a view
      • From: Nick <email@hidden>
References: 
 >The simplest way to fade out a view (From: Nick <email@hidden>)
 >Re: The simplest way to fade out a view (From: Quincey Morris <email@hidden>)
 >Re: The simplest way to fade out a view (From: Gustavo Pizano <email@hidden>)
 >Re: The simplest way to fade out a view (From: Quincey Morris <email@hidden>)
 >Re: The simplest way to fade out a view (From: Nick <email@hidden>)
 >Re: The simplest way to fade out a view (From: Quincey Morris <email@hidden>)
 >Re: The simplest way to fade out a view (From: Nick <email@hidden>)
 >Re: The simplest way to fade out a view (From: Chase Latta <email@hidden>)
 >Re: The simplest way to fade out a view (From: Gustavo Pizano <email@hidden>)
 >Re: The simplest way to fade out a view (From: Nick <email@hidden>)

  • Prev by Date: Re: "Use them from only one thread at a time"
  • Next by Date: Re: "Use them from only one thread at a time"
  • Previous by thread: Re: The simplest way to fade out a view
  • Next by thread: Re: The simplest way to fade out a view
  • Index(es):
    • Date
    • Thread