How To Draw On The Screen With React Native?
Solution 1:
I had issues with all of the other offerings that I could see, especially when upgrading to IOS14 (beta) I could not find any that worked anymore with my project.
I instead created my own drawing component based on pure JavaScript and HTML Canvas. This component has a transparent background so can be overlayed onto any background as well. This also works in online and offline modes.
in it's simplest form you can initialise like this
import RNDrawOnScreen from 'react-native-draw-on-screen';
<RNDrawOnScreen
penColor={'#000'}
strokeWidth={20}
/>
If you pass in a parameter for penColor and strokeWidth these will automatically change when they are updated. You can also call undo and clear methods.
This is Expo friendly and works on IOS/Android only having one dependancy of react-native-webview
in order to render the view.
I have created an npm package for this, hopefully others may find it useful. Included in the package is an example simple expo app which uses the component and creates the simple drawing app shown in the screenshot.
Post a Comment for "How To Draw On The Screen With React Native?"