scenee / FloatingPanel

A clean and easy-to-use floating panel UI component for iOS
MIT License
5.59k stars 508 forks source link

FloatingPanel's contentViewController does not fit properly #464

Open idevChandra6 opened 3 years ago

idevChandra6 commented 3 years ago

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

  1. Instantiate FloatingPanelController (FPC)
  2. Instantiate a UIViewController (VC) from Storyboard
  3. 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)

How many panels do you displays?

Environment

Library version Latest

Installation method

iOS version(s) iOS 14.5.1

Xcode version Version 12.5 (12E262)

scenee commented 3 years ago

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.