Commit f56ae641 authored by Syan's avatar Syan

0.0.6 添加iOS圆形裁剪设置半径参数

parent ec3e24d4
...@@ -92,6 +92,7 @@ import ImagePicker from 'react-native-syan-image-picker' ...@@ -92,6 +92,7 @@ import ImagePicker from 'react-native-syan-image-picker'
CropH: ~~(width * 0.6), // 裁剪高度,默认屏幕宽度60% CropH: ~~(width * 0.6), // 裁剪高度,默认屏幕宽度60%
isGif: false, // 是否允许选择GIF,默认false,暂无回调GIF数据 isGif: false, // 是否允许选择GIF,默认false,暂无回调GIF数据
showCropCircle: false, // 是否显示圆形裁剪区域,默认false showCropCircle: false, // 是否显示圆形裁剪区域,默认false
circleCropRadius: width/2 // 圆形裁剪半径,默认屏幕宽度一半
showCropFrame: true, // 是否显示裁剪区域,默认true showCropFrame: true, // 是否显示裁剪区域,默认true
showCropGrid: false // 是否隐藏裁剪区域网格,默认false showCropGrid: false // 是否隐藏裁剪区域网格,默认false
}; };
......
...@@ -12,11 +12,12 @@ const { width } = Dimensions.get('window'); ...@@ -12,11 +12,12 @@ const { width } = Dimensions.get('window');
const defaultOptions = { const defaultOptions = {
imageCount: 6, // 最大选择图片数目,默认6 imageCount: 6, // 最大选择图片数目,默认6
isCamera: true, // 是否允许用户在内部拍照,默认true isCamera: true, // 是否允许用户在内部拍照,默认true
isCrop: false, // 是否允许裁剪,默认false isCrop: false, // 是否允许裁剪,默认false, imageCount 为1才生效
CropW: ~~(width * 0.6), // 裁剪宽度,默认屏幕宽度60% CropW: ~~(width * 0.6), // 裁剪宽度,默认屏幕宽度60%
CropH: ~~(width * 0.6), // 裁剪高度,默认屏幕宽度60% CropH: ~~(width * 0.6), // 裁剪高度,默认屏幕宽度60%
isGif: false, // 是否允许选择GIF,默认false,暂无回调GIF数据 isGif: false, // 是否允许选择GIF,默认false,暂无回调GIF数据
showCropCircle: false, // 是否显示圆形裁剪区域,默认false showCropCircle: false, // 是否显示圆形裁剪区域,默认false
circleCropRadius: width/2, // 圆形裁剪半径,默认屏幕宽度一半
showCropFrame: true, // 是否显示裁剪区域,默认true showCropFrame: true, // 是否显示裁剪区域,默认true
showCropGrid: false // 是否隐藏裁剪区域网格,默认false showCropGrid: false // 是否隐藏裁剪区域网格,默认false
}; };
......
...@@ -50,6 +50,7 @@ RCT_REMAP_METHOD(asyncShowImagePicker, ...@@ -50,6 +50,7 @@ RCT_REMAP_METHOD(asyncShowImagePicker,
BOOL showCropCircle = [options sy_boolForKey:@"showCropCircle"]; BOOL showCropCircle = [options sy_boolForKey:@"showCropCircle"];
NSInteger CropW = [options sy_integerForKey:@"CropW"]; NSInteger CropW = [options sy_integerForKey:@"CropW"];
NSInteger CropH = [options sy_integerForKey:@"CropH"]; NSInteger CropH = [options sy_integerForKey:@"CropH"];
NSInteger circleCropRadius = [options sy_integerForKey:@"circleCropRadius"];
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:imageCount delegate:nil]; TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:imageCount delegate:nil];
...@@ -68,6 +69,7 @@ RCT_REMAP_METHOD(asyncShowImagePicker, ...@@ -68,6 +69,7 @@ RCT_REMAP_METHOD(asyncShowImagePicker,
if(isCrop){ if(isCrop){
if(showCropCircle) { if(showCropCircle) {
imagePickerVc.needCircleCrop = showCropCircle; //圆形裁剪 imagePickerVc.needCircleCrop = showCropCircle; //圆形裁剪
imagePickerVc.circleCropRadius = circleCropRadius; //圆形半径
} else { } else {
CGFloat x = ([[UIScreen mainScreen] bounds].size.width - CropW) / 2; CGFloat x = ([[UIScreen mainScreen] bounds].size.width - CropW) / 2;
CGFloat y = ([[UIScreen mainScreen] bounds].size.height - CropH) / 2; CGFloat y = ([[UIScreen mainScreen] bounds].size.height - CropH) / 2;
......
{ {
"name": "react-native-syan-image-picker", "name": "react-native-syan-image-picker",
"version": "0.0.5", "version": "0.0.6",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment