HomeiOS DevelopmentVisibility of TextField label in comparison with Picker or Toggle in SwiftUI

Visibility of TextField label in comparison with Picker or Toggle in SwiftUI


If I place a Picker or a Toggle in a SwiftUI Kind, the related label is at all times seen:

Visibility of TextField label in comparison with Picker or Toggle in SwiftUI

However for a TextField, the label is simply proven whereas the sector is empty:

enter image description here

And as quickly as I begin to fill within the TextField, the label disappears.

enter image description here

So now I’ve no context for what the TextField is supposed for.

This is able to not be an issue if the TextField content material is self explanatory, however I’ve a kind with a number of TextFields used to enter numerical values, and as soon as they’re stuffed in I’ve no context for differentiating between every quantity.

Is there any approach to make a SwiftUI TextField behave like a Picker or Toggle, and have the label completely displayed?


Replace:

After attempting out Benzy’s reply of utilizing LabeledContent, I get this kind of consequence when I’ve a number of fields. As you may see the alignment of the TextFields themselves will depend on the size of the textual content within the LabeledContent. I would favor to align the TextFields.

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments