0

i need to display product price as amazon using swift 3. I have tried normal superscripting. But it is not in same alignment. i need exactly as in amazon website along with dollar symbol. i tried this code.. var amountArray = String(format: "%.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
Urmila J
  • 1
  • 2

0 Answers0