(これまでのところ)単純なボタン内にテキストを描画するために、次のコードがあります。
UIImage *buttonImage(CGRect bounds, UIColor *fillColor, NSString *title) {
UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, fillColor.CGColor);
CGContextFillRect(context, bounds);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
[title drawInRect:bounds withFont:PanelButtonFont];
UIGraphicsEndImageContext();
return image;
}
問題の部分はdrawInRect
. それは単に私のテキストを描画していません。フォントは正しく、通常のフォント コードでこれをテストしたので、そうではありません。制作している画像に描いてもらいたいのに気付いていないのではないでしょうか?