I am wanting a UILabel
where each character is underlined and has a background, while also having a space between the background of each individual character - so essentially each character is in it's own "box"
I have tried using attributedText
on a UILabel
but having set the NSBackgroundColorAttributeName
and NSKernAttributeName
the background fills the entire label, essentially I'd like a gap of clear color between each letter.
Is there a way of doing this with attributed text, or will this need to be resolved with another solution?
I currently have tried the following as an example:
NSMutableAttributedString* string = [[NSMutableAttributedString alloc] initWithString:@"EXAMPLE"];
[string addAttribute:NSBackgroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, string.length)]
[string addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, string.length)]
[string addAttribute:NSKernAttributeName value:@(5) range:NSMakeRange(0, [string length])];
[label setAttributedText:string];
(you can ignore the colors, this is just an example)