//***************************************************************************** // 絵文字を一画面分描画 //***************************************************************************** void DrawEmoji(const int page) { const static u16 CodeList[][2] = { // 絵文字のコード {0xe001,0xe05a}, {0xe101,0xe15a}, {0xe201,0xe253}, {0xe301,0xe34d}, {0xe401,0xe44c}, {0xe501,0xe537}, } ; CGRect ViewRect = [[UIScreen mainScreen] bounds] ; CGContextRef ctx = UIGraphicsGetCurrentContext() ; BOOL HighReso = [UIScreen mainScreen].scale == 1.f ? NO : YES ; if(!HighReso) { ViewRect.size.width /= 2.f ; ViewRect.size.height /= 2.f ; } CGContextSetRGBFillColor(ctx,0.f,0.f,0.f,0.f) ; CGContextFillRect(ctx,ViewRect) ; CGAffineTransform tr = HighReso ? CGAffineTransformMakeScale(2.f,2.f) : CGAffineTransformMakeScale(1.f,1.f) ; CGContextSaveGState(ctx) ; CGContextConcatCTM(ctx,tr) ; for(u16 code = CodeList[page][0] ; code <= CodeList[page][1] ; ++ code) { char str[8] ; sprintf(str,"%c%c",code & 0xff,code >> 8) ; float x = ((code & 0xff) % 8) * 20.f - 1.f ; float y = ((code & 0xff) / 8) * 20.f - 1.f ; [ [ [NSString alloc] initWithCharactersNoCopy:(unichar *)str length:1 freeWhenDone:NO ] drawAtPoint:CGPointMake(x,y) withFont:[UIFont systemFontOfSize:20] ] ; } CGContextRestoreGState(ctx) ; } //***************************************************************************** // 描画時に呼ばれる //***************************************************************************** @implementation EmojiView - (void)drawRect:(CGRect)rect { DrawEmoji(0) ; } @end