FloatingPanel
FloatingPanel copied to clipboard
Update panel height programmatically when panel is already presented
Hello, I'm trying to change panel's height in order to adapt it to content, the content arrives later because of API but panel is already presented and shown. I tried to make a func in order to update it but without success, it updates only after changing scroll position with my finger.
Here's my code:
func updatePanelViewHeight() {
guard isViewLoaded else { return }
floatingPanelController?.invalidateLayout()
let productTitleLines = productTitleLabel.numberOfVisibleLines
let productPriceLines = productPriceLabel.numberOfVisibleLines
appFloatingPanelLayout?.heightToAdd = CGFloat(productTitleLines + productPriceLines) + 20
floatingPanelController?.layout = tezenisFloatingPanelLayout!
floatingPanelController?.updateViewConstraints()
floatingPanelController?.viewDidLayoutSubviews()
floatingPanelController?.notifyDidMove()
}
What am I doing wrong? Thanks
FloatingPanelController
expects invalidateLayout()
is called after a new layout is assigned into it. Please see also README - Update your panel layout.
If you call invalidateLayout()
in an animation block. The layout changes with the animation.