FloatingPanel's contentViewController does not fit properly
Description
Setting a UIViewController as contentViewController for a floatingPanel does not fit properly
Expected behavior
The contents of contentViewController's view should fit the floatingPanel properly
Actual behavior
The contents of the view controller stretches beyond the floatingPanel's bounds
Steps to reproduce
- Instantiate
FloatingPanelController(FPC) - Instantiate a
UIViewController(VC) from Storyboard - set the VC as contents for FPC
Code example that reproduces the issue
// Initialize a `FloatingPanelController` object.
floatingPanel = FloatingPanelController()
// Assign self as the delegate of the controller.
floatingPanel.delegate = self
// Set a content view controller.
let contentVC = UIStoryboard(name: "BooksList", bundle: nil).instantiateViewController(withIdentifier: "StoryID_BooksList_VC") as! BooksListVC
contentVC.delegate = self
contentVC.bookID = bookID
floatingPanel.set(contentViewController: contentVC)
// Track a scroll view(or the siblings) in the content view controller.
floatingPanel.track(scrollView: contentVC.tableView)
floatingPanel.isRemovalInteractionEnabled = true
// Create a new appearance.
let appearance = SurfaceAppearance()
// Define shadows
let shadow = SurfaceAppearance.Shadow()
shadow.color = UIColor.black
shadow.offset = CGSize(width: 0, height: 16)
shadow.radius = 16
shadow.spread = 28
appearance.shadows = [shadow]
// Define corner radius and background color
appearance.cornerRadius = 8.0
appearance.backgroundColor = .clear
// Set the new appearance
floatingPanel.surfaceView.appearance = appearance
// floatingPanel.backdropView = backdropVw
floatingPanel.backdropView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleBackdrop(tapGesture:))))
How do you display panel(s)?
self.present(floatingPanel, animated: true, completion: nil)
- Add as child view controllers
- Present modally: Yes
How many panels do you displays?
- 1
Environment
Library version Latest
Installation method
- CocoaPods
iOS version(s) iOS 14.5.1
Xcode version Version 12.5 (12E262)
I'm sorry I can understand what behavior is "properly". One I guess is that you might want the content always fits the visible area of a panel. If so, you are able to use fitToBounds content mode of FloatingPanelController. See also Scale the content view when the surface position changes section in README for more detail.