Skip to content

Commit

Permalink
Fix sizing for iOS13.x (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii authored Mar 8, 2023
1 parent 84a24fc commit cc6860c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/SwiftUIHosting/SwiftUIHostingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ open class SwiftUIHostingView: UIView {

/// Returns calculated size using internal hosting controller
open override func sizeThatFits(_ size: CGSize) -> CGSize {
hostingController.sizeThatFits(in: size)
var fixedSize = size
if fixedSize.width == .infinity {
fixedSize.width = UIView.layoutFittingCompressedSize.width
}
if fixedSize.height == .infinity {
fixedSize.height = UIView.layoutFittingCompressedSize.height
}
return hostingController.sizeThatFits(in: fixedSize)
}

open override func didMoveToWindow() {
Expand Down

0 comments on commit cc6860c

Please sign in to comment.