From e3cb635358eb5f00b7d5d6ab6f1aa0cc9685ab60 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 27 Nov 2019 17:17:03 +0800 Subject: [PATCH] feat:step6 --- iOS/Pod/Classes/Shader/DoricLayouts.m | 12 +++++++++--- iOS/Pod/Classes/Shader/DoricScrollerNode.m | 1 - iOS/Pod/Classes/Shader/DoricSlideItemNode.m | 3 +++ iOS/Pod/Classes/Shader/DoricSliderNode.m | 10 ++++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/iOS/Pod/Classes/Shader/DoricLayouts.m b/iOS/Pod/Classes/Shader/DoricLayouts.m index 883c1625..72214e07 100644 --- a/iOS/Pod/Classes/Shader/DoricLayouts.m +++ b/iOS/Pod/Classes/Shader/DoricLayouts.m @@ -96,6 +96,9 @@ - (CGSize)measureSize:(CGSize)targetSize { - (void)layoutSelf:(CGSize)targetSize { self.width = targetSize.width; self.height = targetSize.height; + for (UIView *view in self.subviews) { + [view layoutSelf:[view measureSize:targetSize]]; + } } - (BOOL)requestSuperview { @@ -202,7 +205,8 @@ - (CGSize)sizeThatFits:(CGSize)size { } - (void)layoutSelf:(CGSize)targetSize { - [super layoutSelf:targetSize]; + self.width = targetSize.width; + self.height = targetSize.height; for (UIView *child in self.subviews) { if (child.isHidden) { continue; @@ -288,7 +292,8 @@ - (CGSize)sizeThatFits:(CGSize)size { } - (void)layoutSelf:(CGSize)targetSize { - [super layoutSelf:targetSize]; + self.width = targetSize.width; + self.height = targetSize.height; CGFloat yStart = 0; if ((self.gravity & TOP) == TOP) { yStart = 0; @@ -378,7 +383,8 @@ - (CGSize)sizeThatFits:(CGSize)size { } - (void)layoutSelf:(CGSize)targetSize { - [super layoutSelf:targetSize]; + self.width = targetSize.width; + self.height = targetSize.height; CGFloat xStart = 0; if (self.contentWeight) { xStart = 0; diff --git a/iOS/Pod/Classes/Shader/DoricScrollerNode.m b/iOS/Pod/Classes/Shader/DoricScrollerNode.m index 091deb79..4d601f15 100644 --- a/iOS/Pod/Classes/Shader/DoricScrollerNode.m +++ b/iOS/Pod/Classes/Shader/DoricScrollerNode.m @@ -41,7 +41,6 @@ - (CGSize)sizeThatFits:(CGSize)size { - (void)layoutSelf:(CGSize)targetSize { [super layoutSelf:targetSize]; - [self.contentView layoutSelf:[self.contentView sizeThatFits:targetSize]]; [self setContentSize:self.contentView.frame.size]; } diff --git a/iOS/Pod/Classes/Shader/DoricSlideItemNode.m b/iOS/Pod/Classes/Shader/DoricSlideItemNode.m index a65cb62e..9e254323 100644 --- a/iOS/Pod/Classes/Shader/DoricSlideItemNode.m +++ b/iOS/Pod/Classes/Shader/DoricSlideItemNode.m @@ -25,6 +25,9 @@ @interface DoricSlideItemView : DoricStackView @end @implementation DoricSlideItemView +- (void)layoutSubviews { + [super layoutSubviews]; +} @end @implementation DoricSlideItemNode diff --git a/iOS/Pod/Classes/Shader/DoricSliderNode.m b/iOS/Pod/Classes/Shader/DoricSliderNode.m index de74db8b..5822745a 100644 --- a/iOS/Pod/Classes/Shader/DoricSliderNode.m +++ b/iOS/Pod/Classes/Shader/DoricSliderNode.m @@ -45,12 +45,18 @@ - (CGSize)sizeThatFits:(CGSize)size { if (self.subviews.count > 0) { CGFloat height = size.height; for (UIView *child in self.subviews) { - height = MAX(child.height, height); + CGSize childSize = [child measureSize:size]; + height = MAX(childSize.height, height); } - return CGSizeMake(height, size.height); + return CGSizeMake(size.width, size.height); } return size; } + +- (void)layoutSelf:(CGSize)targetSize { + [super layoutSelf:targetSize]; + [self reloadData]; +} @end @implementation DoricSliderNode