IOS 5.1 UILabel with Heavy Check Mark ignores TextColor
I am developing an iOS app and have recently "updated" to xCode 4.3.1 and the iOS 5.1 simulator and have a very strange problem with only one character. It's called "Heavy Check Mark" in the character viewer and it looks great in my application on 5.0.1 and below and is colored in .textColor = [UIColor redColor]. In 5.1 it shows up in black in the simulator, and since my phone is jailbroken, I haven't tested it in 5.1 on a real device. If I add another character it will be red, but that particular character will always be black. If I put a space in front of it, it shows up in red, but the spacing is off since I'm using a layer for the border. Below is the actual code, but I tried a simpler shortcut and had the same problem.
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];
Is anyone else having problems with these or other special characters and UILabel.textColor? Any suggested workarounds? I tried to temporarily remove the layer and even create a new minimum label and the same results, black if only this symbol and red if set if any.
source to share
In iOS9, they removed the ability to colorize the heavy checkmark for non-standard fonts as well. This is because it is
U+2714 HEAVY CHECK MARK
included in Apple's emoji character set and it will be drawn as a full color bitmap instead of a single color unicode character.
To prevent this, you can use the symbol
U+FE0E VARIATION SELECTOR-15
. If you change the line to
, you can color it.
isChecked.text = @"\u2714\uFE0E"; isChecked.textColor = [UIColor redColor];
source to share