react-native/ReactKit/Views/UIView+ReactKit.m

43 lines
746 B
Objective-C

// Copyright 2004-present Facebook. All Rights Reserved.
#import "UIView+ReactKit.h"
#import <objc/runtime.h>
#import "RCTAssert.h"
@implementation UIView (ReactKit)
- (NSNumber *)reactTag
{
return objc_getAssociatedObject(self, _cmd);
}
- (void)setReactTag:(NSNumber *)reactTag
{
objc_setAssociatedObject(self, @selector(reactTag), reactTag, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (BOOL)isReactRootView
{
return NO;
}
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
{
[self insertSubview:subview atIndex:atIndex];
}
- (void)removeReactSubview:(UIView *)subview
{
RCTAssert(subview.superview == self, @"");
[subview removeFromSuperview];
}
- (NSArray *)reactSubviews
{
return self.subviews;
}
@end