Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions Sources/StackKit/HStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,7 @@ open class HStackView: UIView {
setNeedsLayout()
layoutIfNeeded()

var _size = size
if size.width == CGFloat.greatestFiniteMagnitude || size.width == 0 {
_size.width = contentSize.width
}
if size.height == CGFloat.greatestFiniteMagnitude || size.height == 0 {
_size.height = contentSize.height
}
return _size
return contentSize
}

open override func sizeToFit() {
Expand Down
9 changes: 5 additions & 4 deletions Sources/StackKit/UIKit+FitSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,29 @@ extension UIView: FitSize {
var size = resolveSize()

if let w = size.width, let h = size.height { // 指定了 size(width & height) 优先使用 size
let size = CGSize(width: w, height: h)
let _ = sizeThatFits(size)
self.frame.size = size
let _ = sizeThatFits(.zero)
self.frame.size = CGSize(width: w, height: h)
return
}

var fitWidth = CGFloat.greatestFiniteMagnitude
var fitHeight = CGFloat.greatestFiniteMagnitude

switch fitType {
case .width, .widthFlexible, .height, .heightFlexible:
case .width, .widthFlexible:
if let w = applyMinMax(toWidth: size.width) {
fitWidth = w
} else {
fitWidth = bounds.width
}

case .height, .heightFlexible:
if let h = applyMinMax(toHeight: size.height) {
fitHeight = h
} else {
fitHeight = bounds.height
}

case .content:
fitWidth = size.width ?? bounds.width
fitHeight = size.height ?? bounds.height
Expand Down
9 changes: 1 addition & 8 deletions Sources/StackKit/VStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,7 @@ open class VStackView: UIView {
setNeedsLayout()
layoutIfNeeded()

var _size = size
if size.width == CGFloat.greatestFiniteMagnitude || size.width == 0 {
_size.width = contentSize.width
}
if size.height == CGFloat.greatestFiniteMagnitude || size.height == 0 {
_size.height = contentSize.height
}
return _size
return contentSize
}

open override func sizeToFit() {
Expand Down