“monde audacieux dans le texte Swift” Réponses codées

Comment gras 1 mot Swift

extension String {
func withBoldText(text: String, font: UIFont? = nil) -> NSAttributedString {
  let _font = font ?? UIFont.systemFont(ofSize: 14, weight: .regular)
  let fullString = NSMutableAttributedString(string: self, attributes: [NSAttributedString.Key.font: _font])
  let boldFontAttribute: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: _font.pointSize)]
  let range = (self as NSString).range(of: text)
  fullString.addAttributes(boldFontAttribute, range: range)
  return fullString
}}


// USE CASE:
       let text = "Discover New Shops.".withBoldText(text: "New")
       label.attributedText =  headerTitle

        
Powerful Peacock

monde audacieux dans le texte Swift

Text("Bold text").bold() + Text("normal text")
Rainbow Otter

Réponses similaires à “monde audacieux dans le texte Swift”

Questions similaires à “monde audacieux dans le texte Swift”

Plus de réponses similaires à “monde audacieux dans le texte Swift” dans Swift

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code