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 :: Swift Overloading with Different Parameter Types 
Swift :: swiftui tap gesture 
Swift :: Create a Tuple 
Swift :: Swift guard Vs if Statement 
Swift :: Log httpurlresponse swift 
Swift :: swift ns_enum generic name 
Swift :: get absolution position of view in swift 
Swift :: Swift Named Tuple 
Swift :: swift - salesforce chat only 
Swift :: Swift static Property 
Swift :: map vs compactmap in swiftui 
Swift :: get character at specifiic location swift 
Swift :: customize change color size MDCActivityIndicator swift 
Swift :: Generic Function Swift 
Swift :: swift constraints 
Swift :: swift_SmtpTransport with oauth2 
Swift :: Swift Syntax of Nested Function 
Swift :: library not found for -lalan-sdk-react-native 
Swift :: xcode enable a button after a text field is filled 
Swift :: how to do corner radius from button image in swift 
Ruby :: see all rails routes in browser 
Ruby :: hashwithindifferentaccess ruby 
Ruby :: how to decrypt credentials in rails 
Ruby :: rails link_to class 
Ruby :: ruby array has element 
Ruby :: ruby make chain method 
Ruby :: ruby get decimal 
Ruby :: ruby generate uuid 
Ruby :: linked list in ruby 
Ruby :: ruby for each continue 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =