in Localizable.strings
"rulesText" = "No illegal posting! \n No weird stuff! \n There is no tolerance for objectionable content, they will be removed!";
Can I make part of this bold? Like No weird stuff! or something in this sense using unicode characters? Or some other way?
I use it like this:
textView.text = "\n\n " + NSLocalizedString("rulesText", comment: "")
Easier way would be using NSMutableAttributedString, while using in textView.text. Here is an example:
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc]
initWithString: NSLocalizedString("rulesText", comment: "")];
[attrString beginEditing];
[attrString addAttribute:kCTFontAttributeName
value:[[UIFont boldSystemFontOfSize:12] fontName]
range:NSMakeRange(2, 4)]; // use range as per your character index range
[attrString endEditing];
Using this it will automatically bold characters which starts from 2nd index and then 4 characters. for example: 1234567890 - 1234567890
Hope this helps.
For SWIFT language:
let font:UIFont? = UIFont.boldSystemFontOfSize(12.0)
myMutableString.addAttribute(NSFontAttributeName, value: font!, range: NSRange(location: 2, length: 4));
http://www.raywenderlich.com/77092/text-kit-tutorial-swift
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With