Skip to content

Commit b2d3648

Browse files
author
JWI
committed
revert those changes and change natural size func
1 parent 4f57264 commit b2d3648

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Sources/UIKitBackend/UIKitBackend+Container.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,16 @@ extension UIKitBackend {
122122
}
123123

124124
public func naturalSize(of widget: Widget) -> SIMD2<Int> {
125-
let size = widget.view.intrinsicContentSize
126-
return SIMD2(
127-
Int(size.width.rounded(.awayFromZero)),
128-
Int(size.height.rounded(.awayFromZero))
129-
)
125+
let view = widget.view
126+
127+
// Use bounds if non-zero, otherwise fallback to screen size
128+
let width = view.bounds.width > 0 ? view.bounds.width : UIScreen.main.bounds.width
129+
let height = view.bounds.height > 0 ? view.bounds.height : UIScreen.main.bounds.height
130+
131+
return SIMD2(Int(width.rounded(.awayFromZero)), Int(height.rounded(.awayFromZero)))
130132
}
131133

134+
132135
public func setSize(of widget: Widget, to size: SIMD2<Int>) {
133136
widget.width = 1000
134137
widget.height = 1000

0 commit comments

Comments
 (0)