Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

how to bold 1 word 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

        
Comment

bold world in text swift

Text("Bold text").bold() + Text("normal text")
Comment

PREVIOUS NEXT
Code Example
Swift :: socket io swift 
Swift :: how to get the path of selected PDF/doc from file manager in ios swift programmatically 
Swift :: how to make text selectable swiftui 
Swift :: guard let swift 
Swift :: date format swift 
Swift :: uilabel set font 
Swift :: swift check if array values are equal 
Swift :: swift extension Array where element 
Swift :: uitextfield set max length 
Swift :: uilabel center text programmatically swift 
Swift :: swift enum storyboard 
Swift :: swift initialize array with size 
Swift :: swiftui refresh view 
Swift :: Swift Create String Instance 
Swift :: bold world in text swift 
Swift :: Swift Weak Reference 
Swift :: Save and Load Data From Keychain ios swift 
Swift :: how to darken view swiftui 
Swift :: map vs compactmap in swiftui 
Swift :: 95 dollars in rupees 
Swift :: helen joseph 
Swift :: Swift Benefits of Using Functions 
Swift :: Speech recognizer swiftui 
Swift :: Swift Literals 
Swift :: swift function parameters 
Swift :: cellwidget to setvalue 
Ruby :: rails get current path 
Ruby :: rails remove reference 
Ruby :: ruby iterate over array 
Ruby :: how to get current month end date in ruby 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =