• 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: Nick <email@hidden>
  • Date: Fri, 20 May 2011 00:03:56 +0300

I only added this "NSViewAnimationEndFrameKey" just to make sure that
any animation happens at all. Yeah it does  happen. But the button
just does not fade out - with or without this
NSViewAnimationEndFrameKey. It waits for 5.0 seconds (as i specified)
and suddenly disappear. It just feels like i ran into one of the
"bugs". Or maybe i am doing something wrong..
This method

-(IBAction)clickMeButton:(id)sender {
	NSLog(@"started");
	NSViewAnimation *viewAnimation = [[NSViewAnimation alloc]
initWithViewAnimations:
									  [NSArray arrayWithObjects:
										[NSDictionary dictionaryWithObjectsAndKeys:
											sender,NSViewAnimationTargetKey,
										NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey,
											nil],
										nil]];

	[viewAnimation setDuration:5.0];
	[viewAnimation startAnimation];
	NSLog(@"ended");
}

behaves as i just described.

2011/5/19 Quincey Morris <email@hidden>:
> On May 19, 2011, at 13:14, Nick wrote:
>
>> Weirdly enough, this does not work:
>>       NSLog(@"started");
>>       NSViewAnimation *viewAnimation = [[NSViewAnimation alloc]
>> initWithViewAnimations:
>>                                                                         [NSArray arrayWithObjects:
>>                                                                               [NSDictionary dictionaryWithObjectsAndKeys:
>>                                                                                       sender,NSViewAnimationTargetKey,
>>                                                                                       NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey,
>>                                                                                       [NSValue valueWithRect:NSMakeRect(200, 200, 200, 200)],
>>
>>                       NSViewAnimationEndFrameKey,
>>                                                                                       nil],
>>                                                                               nil]];
>>
>>       [viewAnimation setDuration:5.0];
>>       [viewAnimation startAnimation];
>>       NSLog(@"ended");
>>
>> the button moves, but it does not fade out. It just disappears from
>> its final location and after a while appears in the middle of the
>> parent View.
>
> You need to experiment with the parameters till you find a combination that gives the visual effect you expect.
>
> IIRC, the documentation is a little confusing because it leads you to believe that specifying a new frame rect is orthogonal to the fade. In fact, I seem to recall, specifying a frame rect indicates that you want the view to be visible at that size and position, and thus conflicts with the fade, producing the kind of inconsistent behavior you're seeing. Try leaving that key out of the dictionary.
>
> The problem, again IIRC, is that only the alpha can change smoothly, not the "isHidden" property, which can only be on or off. The "isHidden" property isn't being animated, just changed at certain points in the animation. You've asked for it to be both on and off at the end of the animation, and one of those wins.
>
> Remember also that NSViewAnimation is a subclass of NSAnimation, so you should be able to use a delegate (for example) to do what you want at the end of the animation.
>
>
>
_______________________________________________

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: Chase Latta <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>)

  • Prev by Date: Re: "Use them from only one thread at a time"
  • Next by Date: Re: The simplest way to fade out a view
  • 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