Guest User

Untitled

a guest
Nov 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. @implementation AppDelegate
  2.  
  3. @synthesize window = _window;
  4. @synthesize box = _box;
  5. @synthesize addButton = _addButton;
  6. @synthesize useDummyAnimationGroup = _useDummyAnimationGroup;
  7.  
  8. - (void)_prepareForFadeIn;
  9. {
  10. [_box setAlphaValue:0];
  11. [_box setHidden:NO];
  12. }
  13.  
  14. - (void)addBoxToWindow:(id)sender;
  15. {
  16. // Both of these branches should have the same effect: the view should fade in smoothly.
  17. // On 10.7, it only works the first time if _useDummyAnimationGroup==YES. After that, it works regardless.
  18. // On 10.8, the fade-in never works the first time. Subsequent fade-ins work.
  19. if (_useDummyAnimationGroup) {
  20. [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
  21. context.duration = 0;
  22.  
  23. [self _prepareForFadeIn];
  24.  
  25. } completionHandler:nil];
  26. } else {
  27.  
  28. [self _prepareForFadeIn];
  29.  
  30. }
  31.  
  32. [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
  33. context.duration = 1;
  34. [_box.animator setAlphaValue:1];
  35. } completionHandler:^{
  36. NSLog(@"Fade in complete!");
  37. }];
  38. }
  39.  
  40. - (void)removeBoxFromWindow:(id)sender;
  41. {
  42. [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
  43. context.duration = 1;
  44. [_box.animator setAlphaValue:0];
  45. } completionHandler:^{
  46. [_box setHidden:YES];
  47. NSLog(@"Fade out complete!");
  48. }];
  49. }
  50.  
  51. @end
Add Comment
Please, Sign In to add comment