Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic height of Bottom Sheet #59

Open
SohaibSiddique opened this issue Apr 18, 2021 · 1 comment
Open

Dynamic height of Bottom Sheet #59

SohaibSiddique opened this issue Apr 18, 2021 · 1 comment

Comments

@SohaibSiddique
Copy link

Hello,

I want to use dynamic height of bottom sheet, I followed the pull to dismiss from example, created a static variable of my content height but before get content height the delegate called,

func sheetPositions(_ availableHeight: CGFloat) -> [CGFloat] { let contentHeight = StudentIDViewController.contentHeight let topPosition = availableHeight - contentHeighy let bottomePosition = 1.1*availableHeight return [topPosition, bottomePosition] }

StudentIDViewController is my bottom sheet VC.

is there another way to doing that, or how can I get my content view height before delegate call.

Thanks

@SohaibSiddique
Copy link
Author

spend the whole night to searching for dynamic height bottom sheet, try different libraries but this one is best of all, so I figured it out how can we use dynamic height for this,

I used separate view and xib file for bottom sheet, constraint your content view to 0 all bottom, top, trailing, leading and then set top constraint relation to greater than or equal, and set the the initial position and positions as below and set you main view background as clear

func sheetPositions(_ availableHeight: CGFloat) -> [CGFloat] {
        return [0.05, 1.1].map{$0*availableHeight} 
}

func initialPosition(_ availableHeight: CGFloat) -> CGFloat {
        return availableHeight*0.05
}

so with all this your bottom sheet cover all the view and your content view will stick to the bottom with all content.
may b this one all help others

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant