Skip to content

Commit

Permalink
Remove reference to UIScreen (not available on visionOS). (#245)
Browse files Browse the repository at this point in the history
* Remove reference to UIScreen (not available on visionOS).
  • Loading branch information
chrisvasselli authored Oct 31, 2023
1 parent 07ec3fd commit ca18d67
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Source/PopTip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,13 @@ 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 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 ca18d67

Please sign in to comment.