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 <quinceymor...@earthlink.net>:
> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to