嘿,你可以试试这个..
let font:UIFont? = UIFont(name: "Helvetica", size:20)
let fontSuper:UIFont? = UIFont(name: "Helvetica", size:10)
let attString:NSMutableAttributedString = NSMutableAttributedString(string: "2.449", attributes: [.font:font!])
attString.setAttributes([.font:fontSuper!,.baselineOffset:5], range: NSRange(location:,length:2))
labelVarName.attributedText = attString