How do you shrink a UIPickerView on the iPhone?

后端 未结 5 2024
梦毁少年i
梦毁少年i 2020-11-29 00:22

I would like to reduce the height of a UIPickerView in my iPhone app, so that it shows only one row and one column. The height of the picker view should be equ

5条回答
  •  天命终不由人
    2020-11-29 01:18

    The answer of user2248258 actually works if you use storyboards and/or autolayout. There I would like to add screenshots as Nilambar suggested.

    1. place a pickerview in another container view with the size you want it

    2. check clipSubviews for the container view

    3. align the picker centered horizontally and vertically in that container view, also give it zero constraints for the trailing and leading place

    This way the picker view gets clipped off to the correct size (won't be resized).

    Result:

提交回复
热议问题