- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *image = [self createImageFromUIColor:[UIColor blackColor]];
}
- (UIImage *)createImageFromUIColor:(UIColor *)color
{
//1x1のBitmapを作成する
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef contextRef = UIGraphicsGetCurrentContext();
//Bitmapを塗りつぶし
CGContextSetFillColorWithColor(contextRef, [color CGColor]);
CGContextFillRect(contextRef, rect);
//UIImageに変換
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
};
2014年3月9日日曜日
[iOS]UIColorからUIImageを作成する
stackoverflow.comより
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿