0
我有兩個屬性字符串,我想將它們放在一個標籤中,我該怎麼做?如何將兩個屬性字符串合併到一個UILabel中?
let font = UIFont(name: "Hidden", size: 15)
let addfont = UIFont(name: "Hidden", size: 15)
var att = [NSFontAttributeName : font]
let attrString = NSAttributedString(
string: animalname[indexPath.row],
attributes: NSDictionary(
object: font!,
forKey: NSFontAttributeName) as! [String : AnyObject])
let attrStringAdd = NSAttributedString(
string: animalloc[indexPath.row],
attributes: NSDictionary(
object: addfont!,
forKey: NSFontAttributeName) as! [String : AnyObject])
cell.animaltext.attributedText = attrString + attrStringAdd
可能重複[如何連接NSAttributedStrings?](http://stackoverflow.com/questions/18518222/how-can-i-concatenate-nsattributedstrings) – juanjo