Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisLitvin committed Aug 26, 2018
1 parent 9c82010 commit 236f9cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ClipLayout.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 15 additions & 14 deletions ClipLayout/Classes/ClipLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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] {

Expand Down

0 comments on commit 236f9cb

Please sign in to comment.