swift apply changes after a word in string
let longString = "Lorem ipsum dolor. VeryLongWord ipsum foobar"
let longestWord = "VeryLongWord"
let longestWordRange = (longString as NSString).rangeOfString(longestWord)
let attributedString = NSMutableAttributedString(string: longString, attributes: [NSFontAttributeName : UIFont.systemFontOfSize(20)])
attributedString.setAttributes([NSFontAttributeName : UIFont.boldSystemFontOfSize(20), NSForegroundColorAttributeName : UIColor.redColor()], range: longestWordRange)
label.attributedText = attributedString
Also in Swift:
- swift 5 make a phone call
- how to change the font of buttons programmatically swift
- UI API called on a background thread
- loop through array swift
- xcode label rotate text
- swift double v float
- store bool value in nsuserdefaults swift
- play sound swift stack overflow
- detect binding valu change swiftui
- how to delete from list tvos swiftui coredata
- How to create a Swift Date object
- parse int in swift
- swift uicollectionview cell size
- conert data to string swift
- change the title of a button using Swift
- how can i find range of a string in another string swift
- how to swift pie chart quartzcore framework
- list header swiftui
- get current unix timestamp swift ios
- swift resource exceeds maximum size
- disable dark mode swift
- register page
- int in swift
- xcode enable a button after a text field is filled