From f3c427ee929d73bad8f080e4456a66dbac219aa5 Mon Sep 17 00:00:00 2001 From: yao <294149113@qq.com> Date: Wed, 18 Dec 2019 13:03:20 +0800 Subject: [PATCH] add image default blur --- Example/Example.xcodeproj/project.pbxproj | 121 +++++++++++++++++++++- Example/Example/DemoLibrary.h | 4 +- Example/Example/DemoVC.m | 2 +- Example/Example/QRScanViewController.m | 2 +- Example/Example/ViewController.m | 2 +- Pod/Classes/Shader/DoricImageNode.m | 17 +++ 6 files changed, 139 insertions(+), 9 deletions(-) diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index a2d131ee..a9b47a06 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -203,6 +203,7 @@ E2334AE822E9D2060098A085 /* Frameworks */, E2334AE922E9D2060098A085 /* Resources */, 223E53E328880489770F8C93 /* [CP] Embed Pods Frameworks */, + EEF1C3B3FE5FE92E603C3B08 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -221,6 +222,8 @@ E2334AFF22E9D2070098A085 /* Sources */, E2334B0022E9D2070098A085 /* Frameworks */, E2334B0122E9D2070098A085 /* Resources */, + 9908F148F5F00DD2EB349A08 /* [CP] Embed Pods Frameworks */, + 17E0A19B8E5C4C4883C8AB85 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -240,6 +243,8 @@ E2334B0A22E9D2070098A085 /* Sources */, E2334B0B22E9D2070098A085 /* Frameworks */, E2334B0C22E9D2070098A085 /* Resources */, + 5FE5475A2ECF1794CBF57C61 /* [CP] Embed Pods Frameworks */, + C09BD0B68592DA6641E3B65D /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -344,21 +349,53 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 17E0A19B8E5C4C4883C8AB85 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 223E53E328880489770F8C93 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/DoricCore/DoricCore.framework", + "${BUILT_PRODUCTS_DIR}/SocketRocket/SocketRocket.framework", + "${BUILT_PRODUCTS_DIR}/YYCache/YYCache.framework", + "${BUILT_PRODUCTS_DIR}/YYImage/YYImage.framework", + "${BUILT_PRODUCTS_DIR}/YYWebImage/YYWebImage.framework", ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DoricCore.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SocketRocket.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYCache.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYImage.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYWebImage.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 48D050F720D3A879060292A8 /* [CP] Check Pods Manifest.lock */ = { @@ -383,6 +420,44 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 5FE5475A2ECF1794CBF57C61 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleUITests/Pods-ExampleUITests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9908F148F5F00DD2EB349A08 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; BE34CD8291B20D26F2ADE3E1 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -405,6 +480,25 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + C09BD0B68592DA6641E3B65D /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleUITests/Pods-ExampleUITests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; E24A030C22EED0D500AB4631 /* Package JS Bundle */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -423,6 +517,25 @@ shellPath = /bin/sh; shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\nexport NVM_DIR=\"$HOME/.nvm\"\n[ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\" # This loads nvm\n[ -s \"$NVM_DIR/bash_completion\" ] && \\. \"$NVM_DIR/bash_completion\" # This loads nvm bash_completion\n\nsh ../../bundle.sh\n"; }; + EEF1C3B3FE5FE92E603C3B08 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/Example/Example/DemoLibrary.h b/Example/Example/DemoLibrary.h index 0fbc97f8..0fa79479 100644 --- a/Example/Example/DemoLibrary.h +++ b/Example/Example/DemoLibrary.h @@ -4,7 +4,7 @@ // #import -#import +#import @interface DemoLibrary : DoricLibrary -@end \ No newline at end of file +@end diff --git a/Example/Example/DemoVC.m b/Example/Example/DemoVC.m index 82d7e40a..25c573c6 100644 --- a/Example/Example/DemoVC.m +++ b/Example/Example/DemoVC.m @@ -4,7 +4,7 @@ // #import "DemoVC.h" -#import +#import @interface DemoVC () @property(nonatomic, copy) NSString *filePath; diff --git a/Example/Example/QRScanViewController.m b/Example/Example/QRScanViewController.m index d963fb69..3bb87fc1 100644 --- a/Example/Example/QRScanViewController.m +++ b/Example/Example/QRScanViewController.m @@ -5,7 +5,7 @@ #import "QRScanViewController.h" #import -#import +#import @interface QRScanViewController () @property(strong, nonatomic) AVCaptureDevice *device; diff --git a/Example/Example/ViewController.m b/Example/Example/ViewController.m index fba9576c..2d05d887 100644 --- a/Example/Example/ViewController.m +++ b/Example/Example/ViewController.m @@ -7,7 +7,7 @@ // #import "ViewController.h" -#import +#import #import "DemoVC.h" #import "QRScanViewController.h" #import "DemoLibrary.h" diff --git a/Pod/Classes/Shader/DoricImageNode.m b/Pod/Classes/Shader/DoricImageNode.m index 95cfd878..66555eda 100644 --- a/Pod/Classes/Shader/DoricImageNode.m +++ b/Pod/Classes/Shader/DoricImageNode.m @@ -26,6 +26,7 @@ @interface DoricImageNode () @property(nonatomic, copy) NSString *loadCallbackId; +@property(nonatomic, assign) BOOL isBlur; @end @implementation DoricImageNode @@ -36,6 +37,15 @@ - (UIImageView *)build { }]; } +- (void)blend:(NSDictionary *)props { + NSInteger value = [props[@"isBlur"] intValue]; + if(value == 1) { + self.isBlur = YES; + } + + [super blend:props]; +} + - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id)prop { if ([@"imageUrl" isEqualToString:name]) { __weak typeof(self) _self = self; @@ -53,6 +63,13 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id } [self requestLayout]; } + + if(self.isBlur) { + UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; + UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:blurEffect]; + effectView.frame = CGRectMake(0, 0, image.size.width, image.size.height); + [view addSubview:effectView]; + } }]; } else if ([@"scaleType" isEqualToString:name]) { switch ([prop integerValue]) {