placeholderText Color

Hi

Theres colors to use in SwiftUI when developing iOS App such as first line, but when I try to use the other system color placeholderText I get the error "Type Color? has no member placeholderText" why ?

Text("Hello, World!").foregroundColor(.quaternaryLabel)               

Accepted Reply

If you want the placeholderText property for SwiftUI's Color, you can access it like this:

Color(uiColor: .placeholderText)

You can also wrap this inside of an extension on Color for simpler code.

Add a Comment

Replies

quaternaryLabel is not defined in SwiftUI but UIKit.

Did you define yourself as an extension to Color ?

No, you mean I should import UIKit or what ? Didn’t get you ? But the quaternaryLabel works without any extension?

  • quaternaryLabel is a property defined on UIColor not Color, so you must have an extension linking the two together.

Add a Comment

If you want the placeholderText property for SwiftUI's Color, you can access it like this:

Color(uiColor: .placeholderText)

You can also wrap this inside of an extension on Color for simpler code.

Add a Comment