Created
March 10, 2015 13:19
-
-
Save frederik-jacques/e7891aac1d585eedd218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Version one | |
-> Expected result | |
String shows Devine rocks, background set to purple for the whole string | |
Background set to red for the word 'rocks' | |
-> Got expected result (http://cl.ly/image/2Q1u0D1B0u0V) | |
*/ | |
let attString = NSMutableAttributedString(string: "Devine rocks"); | |
attString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.purpleColor(), range: NSMakeRange(0, 12)); | |
attString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.redColor(), range: NSMakeRange(7, 5)); | |
/* | |
Version two | |
Take exact the same code as above, but remove the purple background attribute for the whole string. | |
-> Expected result | |
Only have 'rocks' show up in red | |
-> Nope ... the background color is ignored. And everything stays white. (http://cl.ly/image/3g1U0p2Q2x36) | |
*/ | |
let attString = NSMutableAttributedString(string: "Devine rocks"); | |
attString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.redColor(), range: NSMakeRange(7, 5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment