5

My question I think is very simple but I couldn't find anything with Google. I am using NSMutableAttributedString to modify styles in a string and for example I use this code to change the background color:

    [string addAttribute:NSBackgroundColorAttributeName value:[UIColor colorWithRed:0.4 green:0.8 blue:1 alpha:1] range:NSMakeRange(0,18)];

And my question is, how I can round the corners of this background?
Thanks in advance.

DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119
Juan
  • 77
  • 3
  • 7
  • See the two links on the comment there: http://stackoverflow.com/questions/19144145/is-rounded-corners-on-attributed-text-background-possible – Larme Jun 02 '15 at 15:57
  • 1
    possible duplicate of [NSAttributedString background color and rounded corners](http://stackoverflow.com/questions/16362407/nsattributedstring-background-color-and-rounded-corners) – Larme Jun 02 '15 at 15:57
  • I want to do some with this label.layer.cornerRadius = 10; And I don't know how to do with NSMutableAttributedString therefore you don't find in the code – Juan Jun 02 '15 at 15:58
  • I saw all of this before come here and nothing go to me – Juan Jun 02 '15 at 16:01
  • By replacing `CGColorRef highlightColor = (_highlightColor) ? _highlightColor.CGColor : [UIColor yellowColor].[...]CGContextFillRect(context, runBounds);` with `UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:runBounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(3.0f, 3.0f)];[_highlightColor setFill];[path fill];` in the Github project found there (link I gave in previous comment): http://stackoverflow.com/questions/16362407/nsattributedstring-background-color-and-rounded-corners, I already got some results. Still have work to do, but... – Larme Jun 02 '15 at 16:20
  • Any of this go to me... do yo know other solution? @Larme – Juan Jun 03 '15 at 07:36
  • No. Why the previous solution doesn't work for you? What you're trying to do is not simple. – Larme Jun 03 '15 at 08:04

0 Answers0