Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

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
Comment

PREVIOUS NEXT
Code Example
Swift :: declaration of array in swift by two methods. 
Swift :: xcode how to get aspect ratio of device 
Swift :: why launch screen changes appear after 1 day in ios swift 
Swift :: Swift Weak Reference 
Swift :: Swift Symmetric Difference between Two Sets 
Swift :: Swift for Loop inside a while Loop 
Swift :: swift increase int value 
Swift :: Swift Tuple in Switch Statement 
Swift :: parsing to double any data type in swift 
Swift :: Changing default url to static-media in Flask 
Swift :: Swift Create enum variables 
Swift :: special symbol ios swift 
Swift :: how to get list of value from specific keys in array object in swift 
Swift :: swift weekday date component values 
Swift :: swift methods 
Swift :: swift dictionary to json string online 
Swift :: how to unwrap arrays with optional value in swift 
Swift :: Swift Literals 
Swift :: Swift Create Multiple Objects of Class 
Swift :: swiftui lowercase 
Ruby :: kill rails 
Ruby :: activerecord list tables 
Ruby :: authrenticate to artifactory grails 2.1.1 
Ruby :: ruby replace first character in string 
Ruby :: rails distinct 
Ruby :: ruby if statement one line 
Ruby :: ruby array replace element 
Ruby :: how to add font awesome icon in button for submit rails 
Ruby :: ruby debugger 
Ruby :: rbenv and ruby different versions 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =