我需要使用swift 3将产品价格显示为亚马逊。我尝试过正常的上标。但它不是一脉相承的。我需要完全像亚马逊网站上的美元符号。 我试过这段代码.. var amountArray = String(格式:“%。2f”,item.savedAmount).components(separatedBy:“。”)
let font:UIFont? = UIFont(name: "Helvetica", size:18)
let fontSuper:UIFont? = UIFont(name: "Helvetica", size:13)
let attString:NSMutableAttributedString = NSMutableAttributedString(string: "$ \(amountArray[0])\(amountArray[1])", attributes: [NSFontAttributeName:font!])
attString.setAttributes([NSFontAttributeName:fontSuper!,NSBaselineOffsetAttributeName:10], range: NSRange(location:amountArray[0].characters.count+2,length:2))
purchaseAmount.attributedText = attString