头文件导入:
import <CoreText/CoreText.h>
实现方法如下:参数emoji为:😠 这种
- (BOOL)isEmojiSupported:(NSString *)emoji
{
NSData *data = [emoji dataUsingEncoding:NSUTF32LittleEndianStringEncoding];
UTF32Char emojiValue;
[data getBytes:&emojiValue length:sizeof(emojiValue)];
UniChar characters[2] = { };
CFIndex length = (CFStringGetSurrogatePairForLongCharacter(emojiValue, characters) ? 2 : 1);
CGGlyph glyphs[2] = { };
CTFontRef ctFont = CTFontCreateWithName((CFStringRef)@"AppleColorEmoji", 0.0, NULL);
BOOL ret = CTFontGetGlyphsForCharacters(ctFont, characters, glyphs, length);
CFRelease(ctFont);
return ret;
}
网友评论