You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by mo...@apache.org on 2019/04/01 02:39:30 UTC
[incubator-weex] branch master updated: [iOS] Fix the border of
view hasn't gone after changing border width to 0 dynamically; (#2153)
This is an automated email from the ASF dual-hosted git repository.
moshen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new cc9ba8d [iOS] Fix the border of view hasn't gone after changing border width to 0 dynamically; (#2153)
new 2563848 Merge pull request #2215 from NickeyLin/fix/ios-border-issue
cc9ba8d is described below
commit cc9ba8d5c62b6500878fef35e55d5bfdb37dd0d8
Author: Nick.Lin <ti...@sina.com>
AuthorDate: Thu Mar 14 16:23:20 2019 +0800
[iOS] Fix the border of view hasn't gone after changing border width to 0 dynamically; (#2153)
---
.../Sources/Component/WXComponent_internal.h | 2 ++
.../WeexSDK/Sources/Display/WXComponent+Display.m | 30 +++++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
index 3769846..580b3e7 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
@@ -130,6 +130,8 @@ typedef id (^WXDataBindingBlock)(NSDictionary *data, BOOL *needUpdate);
WXBorderStyle _borderBottomStyle;
WXBorderStyle _borderLeftStyle;
+ NSInteger _lastBorderRecords; // Records last border drawing
+
BOOL _isViewTreeIgnored; // Component is added to super, but it is not added to views.
BOOL _isFixed;
BOOL _async;
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index 0d5a2d7..88a3efb 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -31,6 +31,15 @@
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
+typedef NS_ENUM(NSInteger, WXComponentBorderRecord) {
+ WXComponentBorderRecordNone = 0,
+ WXComponentBorderRecordTop = 1,
+ WXComponentBorderRecordRight = 1 << 1,
+ WXComponentBorderRecordBottom = 1 << 2,
+ WXComponentBorderRecordLeft = 1 << 3,
+ WXComponentBorderRecordAll = WXComponentBorderRecordTop | WXComponentBorderRecordRight | WXComponentBorderRecordBottom | WXComponentBorderRecordLeft
+};
+
@implementation WXComponent (Display)
#pragma mark Public
@@ -61,7 +70,7 @@
return YES;
}
- if (![self _needsDrawBorder]) {
+ if (![self _needsDrawBorder] && _lastBorderRecords == WXComponentBorderRecordNone) {
WXLogDebug(@"No need to draw border for %@", self.ref);
WXPerformBlockOnMainThread(^{
[self _resetNativeBorderRadius];
@@ -354,6 +363,9 @@
CGContextAddLineToPoint(context, topLeft, _borderTopWidth/2);
CGContextAddArc(context, topLeft, topLeft, topLeft-_borderTopWidth/2, -M_PI_2, -M_PI_2-M_PI_4-(_borderLeftWidth>0?0:M_PI_4), 1);
CGContextStrokePath(context);
+ _lastBorderRecords |= WXComponentBorderRecordTop;
+ } else {
+ _lastBorderRecords &= ~(WXComponentBorderRecordTop);
}
// Left
@@ -372,6 +384,9 @@
CGContextAddLineToPoint(context, _borderLeftWidth/2, size.height-bottomLeft);
CGContextAddArc(context, bottomLeft, size.height-bottomLeft, bottomLeft-_borderLeftWidth/2, M_PI, M_PI-M_PI_4-(_borderBottomWidth>0?0:M_PI_4), 1);
CGContextStrokePath(context);
+ _lastBorderRecords |= WXComponentBorderRecordLeft;
+ } else {
+ _lastBorderRecords &= ~WXComponentBorderRecordLeft;
}
// Bottom
@@ -390,6 +405,9 @@
CGContextAddLineToPoint(context, size.width-bottomRight, size.height-_borderBottomWidth/2);
CGContextAddArc(context, size.width-bottomRight, size.height-bottomRight, bottomRight-_borderBottomWidth/2, M_PI_2, M_PI_4-(_borderRightWidth > 0?0:M_PI_4), 1);
CGContextStrokePath(context);
+ _lastBorderRecords |= WXComponentBorderRecordBottom;
+ } else {
+ _lastBorderRecords &= ~WXComponentBorderRecordBottom;
}
// Right
@@ -408,9 +426,15 @@
CGContextAddLineToPoint(context, size.width-_borderRightWidth/2, topRight);
CGContextAddArc(context, size.width-topRight, topRight, topRight-_borderRightWidth/2, 0, -M_PI_4-(_borderTopWidth > 0?0:M_PI_4), 1);
CGContextStrokePath(context);
+ _lastBorderRecords |= WXComponentBorderRecordRight;
+ } else {
+ _lastBorderRecords &= ~WXComponentBorderRecordRight;
+ }
+ if (_lastBorderRecords <= 0 || _lastBorderRecords > WXComponentBorderRecordAll) {
+ CGContextClearRect(context, rect);
+ } else {
+ CGContextStrokePath(context);
}
-
- CGContextStrokePath(context);
//clipRadius is beta feature
//TO DO: remove _clipRadius property