Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top