How to make a UIPickerView slide halfway up the screen?

enter image description here

when someone clicks on the clothes, I want the UIPickerView to slide up, as in the example, as follows: enter image description here

Can someone show some sample code?

+6
source share
3 answers

like dsc and Jason said that if you use tableview, use its delegation method didSelectRowAtIndexPath, which calls pickerview in the action sheet.

To learn how to call pickerview on an action sheet, check this link: Add a UIPickerView and a button in the action list - How?

+9
source

Update :
This version is deprecated: use ActionSheetPicker instead.

You can use animation if you want a "sliding" effect.

[pickerView setFrame: CGRectMake([[self view] frame].origin.x, [[self view] frame].origin.y + 480.0, [[self view] frame].size.width, [[self view] frame].size.height)]; [UIView beginAnimations: nil context: NULL]; [UIView setAnimationDuration: 0.25]; [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; [pickerView setFrame: yourDesiredEndFrame]; [UIView commitAnimations]; 

It has not been tested, but will give you an idea.

+7
source

I was also looking for a solution. I found the following: https://github.com/TimCinel/ActionSheetPicker

There is an example project in the zip file that demonstrates how well it works.

Enjoy it!


Update:

This version is deprecated: use ActionSheetPicker-3.0 instead.

+6
source

Source: https://habr.com/ru/post/889176/


All Articles