Re: The simplest way to fade out a view
Re: The simplest way to fade out a view
- Subject: Re: The simplest way to fade out a view
- From: Nick <email@hidden>
- Date: Thu, 19 May 2011 23:14:39 +0300
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.
The CoreAnimation layer is enabled for the main window's view.
Weird
2011/5/19 Quincey Morris <email@hidden>:
> On May 19, 2011, at 11:22, Gustavo Pizano wrote:
>
>> Why will it be a bug?, a fade-in animation goes form 0 to 1 alpha, so at the start point the alpha value must 0 no?
>
> What actually happens in Snow Leopard (IIRC -- it was a few weeks ago that I was using NSViewAnimation) is that the view fades in normally, but at the end of animation it vanishes again because it's still officially hidden. So, the fade-in animation works, but it just doesn't "stick" at the end. You can google the 'NSViewAnimationFadeInEffect' effects key if you want to read more about it.
>
> The *technical* answer to the OP's question is easily findable by googling. However, in this case, the fault is really Apple's. It's hard to know that NSViewAnimation even exists, starting from any obvious place, such as the NSView documentation. The OP and the people who responded can't really be blamed for not realizing there are two intermediate APIs -- NSViewAnimation and NSAnimation -- between the obvious extremes that *are* well-pointed-to in the documentation -- [NSView animator] and layers.
>
>
_______________________________________________
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