Skip to content

Instantly share code, notes, and snippets.

Last active Dec 27, 2021
What would you like to do?
Copyright (C) 2021 mntone. All right reserved. This source code is under MIT license.
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func coloredPrimaryColor(localized: String.LocalizationValue) -> AttributedString {
var attributedString: AttributedString = AttributedString(localized: localized)
guard let firstBoldRange = attributedString.range(of: "**") else { return attributedString }
let orig: AttributedString = attributedString
guard let nextBoldRange = attributedString.range(of: "**") else { return orig }
var attribute: AttributeContainer = AttributeContainer()
attribute.foregroundColor = .primary
attribute.font = .footnote.bold() // MARK: AttributeContainer を生成するのにオリジナルの Font 情報が必要になる
return attributedString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment