Files
react-native-svg/ios/ViewManagers/RNSVGSvgViewManager.m
Horcrux 857b5f5207 Fix Image not rendering the first time svg is displayed
Fix Image not rendering the first time svg is displayed
Add toDataURL method for Svg elements for Android (not finished yet)
2016-08-11 16:27:15 +08:00

38 lines
983 B
Objective-C

/**
* Copyright (c) 2015-present, Horcrux.
* All rights reserved.
*
* This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "RCTBridge.h"
#import "RCTUIManager.h"
#import "RNSVGSvgViewManager.h"
#import "RNSVGSvgView.h"
@implementation RNSVGSvgViewManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [RNSVGSvgView new];
}
RCT_EXPORT_METHOD(toDataURL:(nonnull NSNumber *)reactTag callback:(RCTResponseSenderBlock)callback)
{
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
__kindof UIView *view = viewRegistry[reactTag];
if ([view isKindOfClass:[RNSVGSvgView class]]) {
RNSVGSvgView *svg = view;
callback(@[[svg getDataURL]]);
} else {
RCTLogError(@"Invalid svg returned frin registry, expecting RNSVGSvgView, got: %@", view);
}
}];
}
@end