0

I am trying to draw an attributed string in the UIView and because the char/string is UTF16 I get violet background instead of just the character. I can change any attributes.

When open characters explorer I see the regular version character and with the violet background. When I copy paste the character information I get this:

♊︎ Gemini Unicode: U+264A U+FE0E, UTF-8: E2 99 8A EF B8 8E

This is the drawing code

UIFont *signFont = [UIFont fontWithName:@"Helvetica Neue" size:50];
NSAttributedString *signString = [[NSAttributedString alloc]initWithString:@"♓" attributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:248.0/255.0 green:201.0/255.0 blue:12.0/255.0 alpha:0.6],NSFontAttributeName : signFont} ];
NSLog(@"height %f",(signString.size.height));
[signString drawAtPoint:CGPointMake((self.bounds.size.width/2.0) - (signString.size.width/2.0), (self.bounds.size.height/2.0) - (signString.size.height/2.0))];

Here is an image of characters with and without violet background.

enter image description here

一二三
  • 21,059
  • 11
  • 65
  • 74
Yan
  • 3,533
  • 4
  • 24
  • 45
  • @一二三 I guess that answers why i am getting the violet background character vs not but how do specify in objc to use one or the other? Thanks! – Yan Dec 30 '15 at 03:19
  • 1
    Include the appropriate variation selector in the string. It has nothing to do with the string's attributes or Objective-C. – 一二三 Dec 30 '15 at 03:25
  • I think i got it. Thanks a lot!! Have a great evening! I would you something like this as suggested in the other post [NSString stringWithFormat:@"%@%@",@"\u264A",@"\uFE0E"]; – Yan Dec 30 '15 at 03:25

0 Answers0