Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @implementation AppDelegate
- @synthesize window = _window;
- @synthesize box = _box;
- @synthesize addButton = _addButton;
- @synthesize useDummyAnimationGroup = _useDummyAnimationGroup;
- - (void)_prepareForFadeIn;
- {
- [_box setAlphaValue:0];
- [_box setHidden:NO];
- }
- - (void)addBoxToWindow:(id)sender;
- {
- // Both of these branches should have the same effect: the view should fade in smoothly.
- // On 10.7, it only works the first time if _useDummyAnimationGroup==YES. After that, it works regardless.
- // On 10.8, the fade-in never works the first time. Subsequent fade-ins work.
- if (_useDummyAnimationGroup) {
- [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
- context.duration = 0;
- [self _prepareForFadeIn];
- } completionHandler:nil];
- } else {
- [self _prepareForFadeIn];
- }
- [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
- context.duration = 1;
- [_box.animator setAlphaValue:1];
- } completionHandler:^{
- NSLog(@"Fade in complete!");
- }];
- }
- - (void)removeBoxFromWindow:(id)sender;
- {
- [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
- context.duration = 1;
- [_box.animator setAlphaValue:0];
- } completionHandler:^{
- [_box setHidden:YES];
- NSLog(@"Fade out complete!");
- }];
- }
- @end
Add Comment
Please, Sign In to add comment