From 4103704162ab5e9716d11fd3888d144d103b0355 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 7 Mar 2023 16:33:29 +0800 Subject: [PATCH] iOS: fix when RootNode shrink its size, it cannot be layout properly --- doric-iOS/Pod/Classes/Shader/DoricRootNode.h | 2 ++ doric-iOS/Pod/Classes/Shader/DoricRootNode.m | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricRootNode.h b/doric-iOS/Pod/Classes/Shader/DoricRootNode.h index 6a210cd2..13301e0d 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricRootNode.h +++ b/doric-iOS/Pod/Classes/Shader/DoricRootNode.h @@ -28,6 +28,8 @@ @interface DoricRootNode : DoricStackNode +@property(nonatomic, assign) CGSize mostFrameSize; + - (void)setupRootView:(UIView *)view; @end diff --git a/doric-iOS/Pod/Classes/Shader/DoricRootNode.m b/doric-iOS/Pod/Classes/Shader/DoricRootNode.m index 960ab886..37073ab9 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricRootNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricRootNode.m @@ -54,13 +54,25 @@ - (void)setY:(CGFloat)y { @end @implementation DoricRootNode + +- (instancetype)initWithContext:(DoricContext *)doricContext { + if (self = [super initWithContext:doricContext]) { + _mostFrameSize = CGSizeZero; + } + return self; +} + - (void)setupRootView:(UIView *)view { view.doricLayout.layoutType = DoricStack; self.view = view; } - (void)requestLayout { - [self.view.doricLayout apply]; + if (CGSizeEqualToSize(self.mostFrameSize, CGSizeZero)) { + [self.view.doricLayout apply]; + } else { + [self.view.doricLayout apply:self.mostFrameSize]; + } [super requestLayout]; } @end