- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImage *image = [UIImage imageNamed:@"卡哇伊"];
//生成图片.
//size:开开启一个多大图片上下文.
//opaque:不透度
//scale:0
//开启跟图片相同的大小上下文.
UIGraphicsBeginImageContextWithOptions(image.size, NO, 0.0);
//把图片给绘制图片上下文.
[image drawAtPoint:CGPointZero];
//绘制文字
NSString *str = @"小码哥";
[str drawAtPoint:CGPointZero withAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:20]}];
//生成图片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
//手动关闭上下文
UIGraphicsEndImageContext();
self.imageV.image = newImage;
}
网友评论