skip to Main Content

I looked through the completed version of this lesson, and it also does not show the background color. I’m wondering if this has to do with different versions of Swift/XCode

Expected view

Actual view in project

3

Answers


  1. This is how Picker styled in iOS16 you can try on iOS 15 simulator and see the expected view.

    In Xcode 14.1.3 beta iO16 added NavigationLinkPickerStyle which has the pre iOS 16 behavior.

    You can see detailed answer from here
    https://stackoverflow.com/a/73897344/1000846

    Login or Signup to reply.
  2. I’ve been facing this issue too. It seems that the API for Picker has changed in iOS 16.

    For the sake for working though the tutorial and learning Swift I got past this by installing an older version of iOS. Once I work though the tutorial I can figure out how to upgrade my code to work with iOS 16.

    Go to Window -> Devices and Simulators and install iOS 15.5.

    After you have installed iOS 15.5 you’ll need to change your "Minimum Deployments" to iOS 15.5 in your project file.

    After setting your minimum deployment target to iOS 15.5 you can then select an iOS 15.5 device in Product -> Destination -> iPhone 13 Pro (15.5).

    The tutorial should now work as expected in both the Swift UI Previews in Xcode as well as your device simulator.

    Login or Signup to reply.
  3. If you use the latest version of iOS, in the ThemePicker file you can try to chose picker style. This is how it will looks in iOS 16.2

    var body: some View {
        Picker("Theme", selection: $selection){
            ForEach(Theme.allCases) { theme in
                ThemeView(theme: theme)
                    .tag(theme)
            }
        }
        .pickerStyle(.navigationLink)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search