From 3a1d07ecc4997450713469e1186cd7d85d8643f3 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 15 Oct 2021 19:04:58 +0800 Subject: [PATCH] iOS: FlexLayout's root node do not enable margin --- doric-iOS/Pod/Classes/Shader/DoricFlexNode.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doric-iOS/Pod/Classes/Shader/DoricFlexNode.m b/doric-iOS/Pod/Classes/Shader/DoricFlexNode.m index 21cbd67e..1e2080f7 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricFlexNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricFlexNode.m @@ -236,6 +236,17 @@ - (void)requestLayout { if (self.view.doricLayout.heightSpec != DoricLayoutFit) { self.view.yoga.height = YGPointValue(self.view.height); } + if (![self.superNode isKindOfClass:DoricFlexNode.class]) { + self.view.yoga.margin = YGValueZero; + self.view.yoga.marginLeft = YGValueZero; + self.view.yoga.marginRight = YGValueZero; + self.view.yoga.marginTop = YGValueZero; + self.view.yoga.marginBottom = YGValueZero; + self.view.yoga.marginStart = YGValueZero; + self.view.yoga.marginEnd = YGValueZero; + self.view.yoga.marginVertical = YGValueZero; + self.view.yoga.marginHorizontal = YGValueZero; + } [self.view.yoga applyLayoutPreservingOrigin:YES]; /// Need layout again. for (UIView *view in self.view.subviews) {