I have an attributed string I create like so:
let myMutableString = NSMutableAttributedString(
string: "Father order number:",
attributes: [NSFontAttributeName:UIFont(
name: "Helvetica Neue",
size: 18.0)!])
myMutableString.addAttribute(NSForegroundColorAttributeName, value: UIColor.darkGray, range: NSRange(location: 0, length: myMutableString.length-1))
label1.attributedText = myMutableString
This works fine, and the attributes show up on the simulator. However, when I try to put the attributed string into a function like so, the attributes don't show up when I make the function call.
function call:
let myMutableString:NSMutableAttributedString! = getDarkGrayHelveticaAttributedString(str: "Father order number:")
function use:
label1.attributedText = myMutableString
function:
func getDarkGrayHelveticaAttributedString(str: String) -> NSMutableAttributedString {
var myMutableString = NSMutableAttributedString(
string: str,
attributes: [NSFontAttributeName:UIFont(
name: "Helvetica Neue",
size: 18.0)!])
return myMutableString
}