Skip to content
Browse files

Create a TUICAAction in -[TUIView actionForLayer:forKey:], when anima…

…tions are enabled, so that contained NSViews get animated too
  • Loading branch information...
1 parent eec601a commit f38d9d4a6c51af800774d989b6895c489ee3197e @jspahrsummers jspahrsummers committed
Showing with 24 additions and 2 deletions.
  1. +16 −2 lib/UIKit/TUIView+Animation.m
  2. +8 −0 lib/UIKit/TUIView+Private.h
View
18 lib/UIKit/TUIView+Animation.m
@@ -15,6 +15,8 @@
*/
#import "TUIView.h"
+#import "TUIView+Private.h"
+#import "TUICAAction.h"
@interface TUIViewAnimation : NSObject <CAAction>
{
@@ -294,8 +296,20 @@ - (void)removeAllAnimations
if(animation)
return animation;
}
-
- return (id<CAAction>)[NSNull null];
+
+ if (![TUICAAction interceptsActionForKey:event])
+ return (id<CAAction>)[NSNull null];
+
+ // If we're being called inside the [layer actionForKey:key] call below,
+ // retun nil, so that method will return the default action.
+ if (self.recursingActionForLayer)
+ return nil;
+
+ self.recursingActionForLayer = YES;
+ id<CAAction> innerAction = [layer actionForKey:event];
+ self.recursingActionForLayer = NO;
+
+ return [TUICAAction actionWithAction:innerAction];
}
@end
View
8 lib/UIKit/TUIView+Private.h
@@ -18,6 +18,14 @@
#import "TUITextRenderer.h"
@interface TUIView ()
+/*
+ * Whether we're inside the -actionForLayer:forKey: method.
+ *
+ * This is used so we can get the original action for the key, and wrap it with
+ * extra functionality, without entering an infinite loop.
+ */
+@property (nonatomic, assign, getter = isRecursingActionForLayer) BOOL recursingActionForLayer;
+
@property (nonatomic, retain) NSArray *textRenderers;
- (TUITextRenderer *)textRendererAtPoint:(CGPoint)point;

0 comments on commit f38d9d4

Please sign in to comment.
Something went wrong with that request. Please try again.