Swift Apply Changes After A Word In String

[Solved] Swift Apply Changes After A Word In String | Swift - Code Explorer | yomemimo.com
Question : swift apply changes after a word in string

Answered by : aris-g

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

Source : | Last Update : Thu, 11 Jun 20

Answers related to swift apply changes after a word in string

Code Explorer Popular Question For Swift