Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func setAttributes(price : String)-> NSAttributedString {
- let font:UIFont? = UIFont.boldSystemFont(ofSize: 22)
- let fontSuper:UIFont? = UIFont.boldSystemFont(ofSize: 15)
- let aDotRange = (price as NSString).range(of: ".")
- let attString:NSMutableAttributedString = NSMutableAttributedString(string: price, attributes: [.font:font!])
- attString.setAttributes([.font:fontSuper!,.baselineOffset:5], range: NSRange(location:0,length:1))
- attString.setAttributes([.font:fontSuper!,.baselineOffset:5],
- range: NSRange(location:aDotRange.location,length:4))
- attString.setAttributes([.font:font!],
- range: NSRange(location:1,length:aDotRange.location - 1 ))
- attString.setAttributes([.font:fontSuper!],
- range: NSRange(location:aDotRange.location + 4,
- length: (price.count) - (aDotRange.location + 4) ))
- return attString
- }
- lblPrice.attributedText = self.setAttributes(price: "$249.99 / mon")
- lblPrice.layer.cornerRadius = 4
- lblPrice.layer.borderWidth = 1.0
- lblPrice.layer.borderColor = UIColor.blue.cgColor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement