From afff5b9be0500ca6506a118862cb13c98ac77890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Fri, 17 Apr 2020 14:12:51 +0800 Subject: [PATCH] add scale --- doric-demo/src/ImageDemo.ts | 4 ++-- doric-iOS/Pod/Classes/Shader/DoricImageNode.m | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doric-demo/src/ImageDemo.ts b/doric-demo/src/ImageDemo.ts index 1335781f..bdedd666 100644 --- a/doric-demo/src/ImageDemo.ts +++ b/doric-demo/src/ImageDemo.ts @@ -121,8 +121,8 @@ class ImageDemo extends Panel { stretchInset: { left: 374, top: 0, - right: 375, - bottom: 198 + right: 66, + bottom: 0 } }) ], diff --git a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m index dad81030..c9c965b8 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m @@ -228,12 +228,12 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id } } else if ([@"stretchInset" isEqualToString:name]) { NSDictionary * stretchInsetDic = (NSDictionary *)prop; - int left = [stretchInsetDic[@"left"] intValue]; - int top = [stretchInsetDic[@"top"] intValue]; - int right = [stretchInsetDic[@"right"] intValue]; - int bottom = [stretchInsetDic[@"bottom"] intValue]; - - UIImage *result = [view.image resizableImageWithCapInsets:UIEdgeInsetsMake(top - 0.1, left - 0.1, bottom - 0.1, view.image.size.width - right + 0.1) resizingMode:UIImageResizingModeStretch]; + CGFloat left = [stretchInsetDic[@"left"] floatValue]; + CGFloat top = [stretchInsetDic[@"top"] floatValue]; + CGFloat right = [stretchInsetDic[@"right"] floatValue]; + CGFloat bottom = [stretchInsetDic[@"bottom"] floatValue]; + UIImage *scaled = [[UIImage alloc] initWithCGImage:view.image.CGImage scale:[[UIScreen mainScreen] scale] orientation:view.image.imageOrientation]; + UIImage *result = [scaled resizableImageWithCapInsets:UIEdgeInsetsMake(0, 125, 0, 22) resizingMode:UIImageResizingModeStretch]; view.image = result; } else { [super blendView:view forPropName:name propValue:prop];