iOS 检测emoji 当前系统是否支持展示

头文件导入:

import

实现方法如下:参数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;
}

你可能感兴趣的:(iOS 检测emoji 当前系统是否支持展示)