Is Rounded Corners on Attributed Text Background possible?

Jeanette Müller picture Jeanette Müller · Oct 2, 2013 · Viewed 7k times · Source

I attributed Text with different textcolors. For better readability on highlighted text i use backgroundcolor. Is it possible to bring the CALayer Effect of Rounded Corners on this Textarea? Not the whole Area but the special Text inside of it.

My Code:

NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"Highlighted Text"
                                                                          attributes:@{
                                                                                       NSFontAttributeName:            [UIFont fontWithName:@"HelveticaNeue" size:10.0f],
                                                                                       NSForegroundColorAttributeName: [UIColor lightGrayColor],
                                                                                       NSBackgroundColorAttributeName: [UIColor darkGrayColor]
                                                                                       }];

Answer