Skip to content

Commit

Permalink
Remove reference to UIScreen (not available on visionOS).
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvasselli committed Oct 27, 2023
1 parent 07ec3fd commit 1228af9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/PopTip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,14 @@ open class PopTip: UIView {
containerView = view
let controller = UIHostingController(rootView: rootView)
controller.view.backgroundColor = .clear
let maxContentWidth = UIScreen.main.bounds.width - (self.edgeMargin * 2) - self.edgeInsets.horizontal - (self.padding * 2)
let window = parent.view.window
let maxContentWidth: CGFloat
if let window = parent.view.window {
maxContentWidth = window.bounds.width - (self.edgeMargin * 2) - self.edgeInsets.horizontal - (self.padding * 2)
}
else {
maxContentWidth = .greatestFiniteMagnitude
}
let sizeThatFits = controller.view.sizeThatFits(CGSize(width: maxContentWidth, height: CGFloat.greatestFiniteMagnitude))
controller.view.frame.size = CGSize(width: min(sizeThatFits.width, maxContentWidth), height: sizeThatFits.height)
maxWidth = controller.view.frame.size.width
Expand Down

0 comments on commit 1228af9

Please sign in to comment.