WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

labelsHidden() not working

Forums > SwiftUI

Can somebody perhaps confirm that the labelsHidden() does not work on Picker as described in https://www.hackingwithswift.com/quick-start/swiftui/how-to-hide-the-label-of-a-picker-stepper-toggle-and-more-using-labelshidden

(but it does work on Toggle control)

Is this "by design" or is this a bug and I should file Apple a feedback for it?

NavigationView {
    Form {
        Picker("Select a number", selection: $selectedNumber) {
            ForEach(0..<10, id: \.self) {
                Text("\($0)").tag($0)
            }
        }

        Picker("Hidden label", selection: $selectedNumber) {
            ForEach(0..<10, id: \.self) {
                Text("\($0)").tag($0)
            }
        }
        .labelsHidden()
    }
}

1      

Works for me using Xcode 11.7. I haven't upgraded to Xcode 12 yet so can't confirm if it's working there or not.

picker label hidden

1      

Hi

Tried it both 11.7 hides label, and in 12 beta 6 does not hid label

But interesting when using the .pickerStyle(WheelPickerStyle()) it hides the label, when in 11.7 it does not unless you use .labelsHidden() as well

So maybe it change to do that 🤔

Nigel

1      

Thanks, i've filed FB8704602 at https://feedbackassistant.apple.com because I consider this a regression.

Perhaps this bug has sneaked in while they fixed something else. I hope they will fix that, as the current style with a label is sometimes really ugly (depends on the controls above and below the Picker).

1      

I just leaved a blank space to the label area :)

1      

Hacking with Swift is sponsored by Emerge

SPONSORED Why are Swift reference types bad for app startup time, and what’s the performance cost of protocol conformances? That’s just a couple of the topics you can learn about on the Emerge blog — written by the app performance experts behind Emerge’s advanced app optimization and monitoring tools, based on their experience of working at companies like Apple, Airbnb, Snap, and Spotify.

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.