iOS 8+
Android 17+
TOCropViewController for iOS
uCrop for Android
Run tns plugin add nativescript-imagecropper
This plugin is designed according to {N} 2.0 Specs. For Android, you will need to modify the AndroidManifest.xml file.
Add the following to the AndroidManifest.xml
<manifest>
<application>
<activityandroid:name="com.yalantis.ucrop.UCropActivity"android:screenOrientation="portrait"/>
</application>
</manifest>To use the image cropping module you must first require it.
varicModule=require("nativescript-imagecropper");show(ImageSource): Returns a cropped ImageSource
varcropper=newicModule.ImageCropper();cropper.show(picture).then(function(args){console.log(JSON.stringify(args));}).catch(function(e){console.log(e);});show(ImageSource,Options): Returns a cropped and resized ImageSource
varcropper=newicModule.ImageCropper();cropper.show(picture,{width:300,height:300}).then(function(args){console.log(JSON.stringify(args));}).catch(function(e){console.log(e);});| Option | Type | Description |
|---|---|---|
| width | number | The width of the image you would like returned. |
| height | number | The height of the image you would like returned. |
| Argument | Type | Result(s) |
|---|---|---|
| response | string | Success Cancelled Error |
| image | ImageSource | null if there was an error or was cancelledImageSource on success |