From 3d403d51780cb182326c3620f2e33c6e9662da24 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 10 Dec 2019 14:15:32 +0800 Subject: [PATCH] feat:fix padding compute --- Pod/Classes/Shader/DoricLayouts.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Pod/Classes/Shader/DoricLayouts.m b/Pod/Classes/Shader/DoricLayouts.m index 2d1d4c40..176eb18b 100644 --- a/Pod/Classes/Shader/DoricLayouts.m +++ b/Pod/Classes/Shader/DoricLayouts.m @@ -251,7 +251,7 @@ - (void)layoutSelf:(CGSize)targetSize { } else if ((gravity & RIGHT) == RIGHT) { child.right = targetSize.width - padding.right; } else if ((gravity & CENTER_X) == CENTER_X) { - child.centerX = (targetSize.width - padding.left - padding.right) / 2; + child.centerX = targetSize.width / 2; } else { if (childConfig.margin.left) { child.left = childConfig.margin.left + padding.left; @@ -264,7 +264,7 @@ - (void)layoutSelf:(CGSize)targetSize { } else if ((gravity & BOTTOM) == BOTTOM) { child.bottom = targetSize.height - padding.bottom; } else if ((gravity & CENTER_Y) == CENTER_Y) { - child.centerY = (targetSize.height - padding.top - padding.bottom) / 2; + child.centerY = targetSize.height / 2; } else { if (childConfig.margin.top) { child.top = childConfig.margin.top + padding.top; @@ -323,7 +323,7 @@ - (void)layoutSelf:(CGSize)targetSize { } else if ((self.gravity & BOTTOM) == BOTTOM) { yStart = targetSize.height - self.contentHeight - padding.bottom; } else if ((self.gravity & CENTER_Y) == CENTER_Y) { - yStart = (targetSize.height - self.contentHeight - padding.top - padding.bottom) / 2; + yStart = (targetSize.height - self.contentHeight - padding.top - padding.bottom) / 2 + padding.top; } CGFloat remain = targetSize.height - self.contentHeight - padding.top - padding.bottom; for (UIView *child in self.subviews) { @@ -351,7 +351,7 @@ - (void)layoutSelf:(CGSize)targetSize { } else if ((gravity & RIGHT) == RIGHT) { child.right = self.width - padding.right; } else if ((gravity & CENTER_X) == CENTER_X) { - child.centerX = (targetSize.width - padding.left - padding.right) / 2; + child.centerX = targetSize.width / 2; } else if (childConfig.margin.left) { child.left = childConfig.margin.left + padding.left; } else if (childConfig.margin.right) { @@ -414,7 +414,7 @@ - (void)layoutSelf:(CGSize)targetSize { } else if ((self.gravity & RIGHT) == RIGHT) { xStart = targetSize.width - self.contentWidth - padding.right; } else if ((self.gravity & CENTER_X) == CENTER_X) { - xStart = (targetSize.width - self.contentWidth - padding.left - padding.right) / 2; + xStart = (targetSize.width - self.contentWidth - padding.left - padding.right) / 2 + padding.left; } CGFloat remain = targetSize.width - self.contentWidth - padding.left - padding.right; for (UIView *child in self.subviews) { @@ -444,7 +444,7 @@ - (void)layoutSelf:(CGSize)targetSize { } else if ((gravity & BOTTOM) == BOTTOM) { child.bottom = targetSize.height - padding.bottom; } else if ((gravity & CENTER_Y) == CENTER_Y) { - child.centerY = (targetSize.height - padding.top - padding.bottom) / 2; + child.centerY = targetSize.height / 2; } else if (childConfig.margin.top) { child.top = childConfig.margin.top + padding.top; } else if (childConfig.margin.bottom) {