From 236f9cb577a33cfb3225f84c105440a259b88ec2 Mon Sep 17 00:00:00 2001 From: Denis Litvin Date: Sun, 26 Aug 2018 11:34:49 -0700 Subject: [PATCH] Bug fixes --- ClipLayout.podspec | 2 +- ClipLayout/Classes/ClipLayout.swift | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ClipLayout.podspec b/ClipLayout.podspec index 19329f9..c2eb0b7 100644 --- a/ClipLayout.podspec +++ b/ClipLayout.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'ClipLayout' - s.version = '1.2.6' + s.version = '1.2.7' s.summary = "Simple and performant Layout Engine. It's faster and more concise AutoLayout alternative :)" # This description is used to generate tags and improve search results. diff --git a/ClipLayout/Classes/ClipLayout.swift b/ClipLayout/Classes/ClipLayout.swift index d53455e..1243089 100644 --- a/ClipLayout/Classes/ClipLayout.swift +++ b/ClipLayout/Classes/ClipLayout.swift @@ -305,17 +305,7 @@ public class ClipLayout: NSObject { if cache.height == 0 { cache.height = size.height } } if cache.width == 0 { cache.width = width } - - //Allow view to adjust height if width will be trimmed - //Primarily for UITextInput - if distribution == .row { - let subviews = view.subviews.filter { $0.clip.enable } - let widths = trimmedWidths(for: subviews, within: sizeBounds) - for i in 0 ..< subviews.count { - subviews[i].clip.invalidateCache() - subviews[i].clip.cache.width = widths[i] - } - } + adjustForTextInputs(within: sizeBounds) return min(width, sizeBounds.width) } @@ -351,12 +341,23 @@ public class ClipLayout: NSObject { cache.width = size.width } } - if cache.height == 0 { - cache.height = height - } + if cache.height == 0 { cache.height = height } + adjustForTextInputs(within: sizeBounds) return min(height, sizeBounds.height) } + private func adjustForTextInputs(within sizeBounds: CGSize) { + //Allow view to adjust height if width will be trimmed + //Primarily for UITextInput + if distribution == .row { + let subviews = view.subviews.filter { $0.clip.enable } + let widths = trimmedWidths(for: subviews, within: sizeBounds) + for i in 0 ..< subviews.count { + subviews[i].clip.invalidateCache() + subviews[i].clip.cache.width = widths[i] + } + } + } private func trimmedHeights(for subviews: [UIView], within size: CGSize) -> [CGFloat] {