SwiftUI_visionOS_Note

Picker()

Jan 16, 2024
  • Picker() is an ideal component for any situation where a user needs to select options.
  • Different styles and formats can be applied, each better suited to either large or smaller data sets.

    1. Write a default picker code

     

    2. Bind the string into selection

    • change the tag number into string
     
    • Create Text with Age and selected value in HStack
     
     

    3. Use ForEach instead of writing one by one.

    • Now picker has a number from 18 to 99
     

    4. Stylize the Picker

    1. We can change the background
     
    1. Stylize the text inside
     
    Callout icon'
    It’s working on .inline
     
     
    1. Use .pickerStyle()
    • Slider
     
    • Inline, allows the customization
     
     
     
     

    You might also like

    BlogPro logo
    Made with BlogPro