add toDataURL method for svg elements

Add toDataURL method for svg elements to get data64 data  of svg.(iOS)
Add example for this.
This commit is contained in:
Horcrux
2016-08-10 16:54:48 +08:00
parent f118ae2d67
commit 76a3e8e32d
5 changed files with 89 additions and 13 deletions
+17 -2
View File
@@ -1,7 +1,18 @@
import React, {Component, PropTypes} from 'react';
import {View, requireNativeComponent, StyleSheet} from 'react-native';
import React, {
Component,
PropTypes
} from 'react';
import {
View,
requireNativeComponent,
StyleSheet,
UIManager,
findNodeHandle,
NativeModules
} from 'react-native';
import ViewBox from './ViewBox';
import _ from 'lodash';
const RNSVGSvgViewManager = NativeModules.RNSVGSvgViewManager;
// Svg - Root node of all Svg elements
let id = 0;
@@ -45,6 +56,10 @@ class Svg extends Component{
this.root.setNativeProps(...args);
};
toDataURL = (callback = _.noop) => {
RNSVGSvgViewManager.toDataURL(findNodeHandle(this.root), callback);
};
render() {
let {props} = this;
let opacity = +props.opacity;