3

I've been developing an iOS app and recently "upgraded" to xCode 4.3.1 and the iOS 5.1 simulator and have a very strange issue with just one character. It's called "Heavy Check Mark" in the character viewer and it looks great in my app in 5.0.1 and below and is colored with a .textColor = [UIColor redColor]. In 5.1 it shows up black in the simulator and since my phone is jailbroken I haven't checked it in 5.1 on an actual device. If I put in any other character it shows up red, but this one specific character always shows black. If I put a space before it it shows up red but the spacing is off as I'm using a layer to border. Below is actual code, but I've tried a simpler label and have the same issue.

        isChecked = [[[UILabel alloc] initWithFrame:CGRectMake(20.0,9.0,20,20)] autorelease];
        isChecked.font = [UIFont boldSystemFontOfSize:24.0];
        isChecked.backgroundColor = [UIColor clearColor];
        isChecked.textColor = [UIColor redColor];
        isChecked.layer.borderColor = [UIColor blackColor].CGColor;
        isChecked.layer.borderWidth = 2.0;
        isChecked.text = @"✔";
        isChecked.tag = 2;
        [cell.contentView addSubview:isChecked];

Anyone else experiencing problems with this or other special characters and UILabel.textColor? Any suggested workarounds? I've tried temporarily removing the layer and even creating a new minimal label and same results black if this character only and red as set if any other.

skymatt70
  • 53
  • 1
  • 6
  • What happens if you use the unicode escape (@"\u_whatever_") instead of having the unicode character in your source code? I remember reading somewhere that putting unicode characters in your source was a bad idea, but I don't have a definitive source for that. – jrturton Mar 13 '12 at 17:33
  • Update and fix that works for me, but still very strange. If anyone else ran into this obscure issue I found that using a named font instead of system font seems to fix it. – skymatt70 Mar 13 '12 at 17:38
  • @jrturton, great suggestion and it behaves the same. Always black if just that character and system font, but I'll leave the @"\u2714" as I agree it's more precise if reading the code. – skymatt70 Mar 13 '12 at 17:43
  • You should put your fix as an answer, you can accept it yourself later. Glad you got it working, it might be worth opening a bug report about this. – jrturton Mar 13 '12 at 18:31

2 Answers2

1

In iOS9 they have removed the possibility to colour the heavy checkmark also for non-standard fonts. This is because the U+2714 HEAVY CHECK MARK is included in Apple's set of emoji characters and it will be drawn as a full-colour bitmap instead of a single-colour unicode character.

The way to prevent this from happening, you could use a U+FE0E VARIATION SELECTOR-15 character. If you change the string to @"\u2714\uFE0E" you would be able to colour it.

isChecked.text = @"\u2714\uFE0E";
isChecked.textColor = [UIColor redColor];
masam
  • 2,268
  • 1
  • 22
  • 24
  • Regarding the color, this works - however in my case, the size of the checkmark was also significantly reduced. – Jekapa Oct 11 '19 at 16:48
1

Update and fix that works for me, but still very strange. If anyone else ran into this obscure issue I found that using a named font instead of system font seems to fix it.

skymatt70
  • 53
  • 1
  • 6
  • 1
    I don't know about you, but I was only able to make it work if the named font was specifically Zapf Dingbats; no other font (that I found) seems to have that character, so it would fall back to the Emoji graphic that they apparently added for it in 5.1. – zem Apr 06 '12 at 19:14
  • 1
    zem, I'm using "Arial Unicode MS" and the \u2714 character and am able to color it red. – skymatt70 Apr 06 '12 at 23:21
  • Strange. I saw that Arial Unicode MS was another font with that glyph in character viewer, but it's not an option for me in interface builder on an iOS project. Maybe it can be specified in code but not there? – zem Apr 07 '12 at 00:09
  • zem, Very strange indeed. I'm not using IB, but I just verified it's not listed there, but I did find a post that shows it is available in iOS. I also experimented a bit with my code and found the problem existed for every font I tried except for Arial Unicode MS. I'm glad I stumbled upon it. Maybe in your viewDidLoad you could set it. – skymatt70 Apr 07 '12 at 00:40
  • well, Zapf Dingbats works fine and is selectable, so I don't need to bother with that unless I wanted specifically the Arial version for some reason. I'm guessing Arial Unicode isn't directly selectable in IB because it's supposed to be a fallback for unicode characters that aren't in other fonts, but for whatever reason it's first falling back to this goofy new graphic. – zem Apr 07 '12 at 21:21
  • 1
    Here are two other check marks that may work: ☑✓ And also a green Emoji2 check mark that is always green:✅ cmd+option+t = Unicode character index on Macs... Hope this helped! – Albert Renshaw Sep 06 '12 at 22:48