Skip to content

Commit

Permalink
Fix floating panel content view constraints (#549)
Browse files Browse the repository at this point in the history
Resolved Maps-SwiftUI Example Animation Stuttering (#546)
  • Loading branch information
seanlh authored Jun 13, 2022
1 parent bacc871 commit 8909267
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Examples/Maps-SwiftUI/Maps/FloatingPanel/FloatingPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,20 @@ struct FloatingPanelView<Content: View, FloatingPanelContent: View>: UIViewContr
ignoresKeyboard: true
)
hostingViewController.view.backgroundColor = nil
fpc.set(contentViewController: hostingViewController)
let contentViewController = UIViewController()
contentViewController.view.addSubview(hostingViewController.view)
fpc.set(contentViewController: contentViewController)
fpc.addPanel(toParent: parentViewController, at: 1, animated: false)

hostingViewController.view.translatesAutoresizingMaskIntoConstraints = false
let bottomConstraint = hostingViewController.view.bottomAnchor.constraint(equalTo: contentViewController.view.bottomAnchor)
bottomConstraint.priority = .defaultHigh
NSLayoutConstraint.activate([
hostingViewController.view.topAnchor.constraint(equalTo: contentViewController.view.topAnchor),
hostingViewController.view.leadingAnchor.constraint(equalTo: contentViewController.view.leadingAnchor),
hostingViewController.view.trailingAnchor.constraint(equalTo: contentViewController.view.trailingAnchor),
bottomConstraint
])
}

func updateIfNeeded() {
Expand Down

0 comments on commit 8909267

Please sign in to comment.