when I'm using NSForegroundColorAttributeName with a string that includes an emoji the string is displaced vertically.
Here's an example:
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 21)];
label1.text = @"@Hashtag";
//label1.backgroundColor = [UIColor redColor];
label1.numberOfLines = 0;
label1.shadowColor = [UIColor colorWithWhite:1 alpha:0.5];
label1.shadowOffset = CGSizeMake(1,1);
[label1 sizeToFit];
[self.view addSubview:label1];
NSString *comment = @"@Hashtag ";
NSMutableAttributedString *commentAttributedString = [[NSMutableAttributedString alloc] initWithString:comment];
[commentAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(0, comment.length)];
[commentAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, 8)];
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 21)];
label2.attributedText = commentAttributedString;
label2.numberOfLines = 0;
label2.shadowColor = [UIColor colorWithWhite:1 alpha:0.5];
label2.shadowOffset = CGSizeMake(1,1);
[label2 sizeToFit];
[self.view addSubview:label2];
I get the following result:
The green label is displaced. This happens only with iOS 7, with iOS 6 everything works fine.
Does anybody know why this happens?
Kind regards
Arno