File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -50,26 +50,26 @@ public final class StackView: View {
5050 }
5151
5252 public override func contentSize( ) -> Size2 {
53+ for subview in self . subviews {
54+ subview. layoutIfNeeded ( )
55+ }
56+ let spacingSize : Float = spacing * Float( subviews. count - 1 )
5357 switch axis {
5458 case . horizontal:
5559 return Size2 (
56- width: subviews. last? . frame. maxX ?? 0 ,
57- height: ( subviews. sorted ( by: { $0. bounds . height > $1. bounds . height} ) . first ? . bounds . height ?? 0 ) + ( spacing * Float ( subviews . count - 1 ) )
60+ width: subviews. sorted ( by : { $0 . frame . maxX < $1 . frame . maxX } ) . last? . frame. maxX ?? 0 ,
61+ height: ( subviews. sorted ( by: { $0. frame . height < $1. frame . height} ) . last ? . frame . height ?? 0 ) + spacingSize
5862 )
5963 case . vertical:
6064 return Size2 (
61- width: ( subviews. sorted ( by: { $0. bounds . width > $1. bounds . width} ) . first ? . bounds . width ?? 0 ) + ( spacing * Float ( subviews . count - 1 ) ) ,
62- height: subviews. last? . frame. maxY ?? 0
65+ width: ( subviews. sorted ( by: { $0. frame . width < $1. frame . width} ) . last ? . frame . width ?? 0 ) + spacingSize ,
66+ height: subviews. sorted ( by : { $0 . frame . maxY < $1 . frame . maxY } ) . last? . frame. maxY ?? 0
6367 )
6468 }
6569 }
6670
6771 public override func updateLayoutConstraints( ) {
68- if subviews. isEmpty {
69- self . widthAnchor. constrain ( to: 0 )
70- self . heightAnchor. constrain ( to: 0 )
71- return
72- }
72+ if subviews. isEmpty { return }
7373 switch axis {
7474 case . horizontal:
7575 switch distribution {
You can’t perform that action at this time.
0 commit comments