Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributedString example broken #84

Open
tillkruss opened this issue Apr 30, 2024 · 1 comment
Open

AttributedString example broken #84

tillkruss opened this issue Apr 30, 2024 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@tillkruss
Copy link

tillkruss commented Apr 30, 2024

What happened?

This code:

title: .init(
text: .init(
"What's New in "
+ AttributedString(
"Translate",
attributes: .foregroundColor(.cyan)
)
)
),

Does not build with iOS 17.x in a SwiftUI app:

Cannot infer contextual base in reference to member 'cyan'
Type 'AttributeContainer' has no member 'foregroundColor'

Is there a way to highlight a word using the latest version?

What are the steps to reproduce?

Build with iOS 17.x

What is the expected behavior?

It to build.

@tillkruss tillkruss added the bug Something isn't working label Apr 30, 2024
@SvenTiigi
Copy link
Owner

Hi @tillkruss,

the example application is building successfully with iOS 17.X with this action run.

If you are using the code snippet included in your issue description outside the example application of the WhatsNewKit you need to ensure that the following extension is included since this extension adds a foregroundColor static function on an AttributeContainer

// MARK: - AttributeContainer+foregroundColor
private extension AttributeContainer {
/// A AttributeContainer with a given foreground color
/// - Parameter color: The foreground color
static func foregroundColor(
_ color: Color
) -> Self {
var container = Self()
container.foregroundColor = color
return container
}
}

@SvenTiigi SvenTiigi added help wanted Extra attention is needed and removed bug Something isn't working labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants