I am trying to draw circle behind particular parts of UILabel characters without having to use several labels or recompute frames.
I know that I can insert an image into UILabel using attributed text but I want the circle to stand behind the numbers (from 1 to 9). I don't want to store images from 1 to 9. I also cannot find any pod achieving this.
let fullText = NSMutableAttributedString()
let imageAttachment = NSTextAttachment()
imageAttachment.image = UIImage(named: "\(number)_\(color == .yellow ? "yellow" : "gray")")
let imageString = NSAttributedString(attachment: imageAttachment)
let endString = NSAttributedString("nouveaux")
fullString.append(imageString)
fullString.append(endString)
mainLabel.attributedText = fullString
EDIT
I want to draw circle behind each digit of a string. I would like it to be a generic tool if possible, some kind of parser that returns an attributed string if possible, a unique UIView if not. Another use case is "4 messages | chat 2" (4 being yellow, 2 being gray)






