这是同步我的应用程序,我想要的是我想将图像显示为联系人图片和消息,如下面的带文本的透明矩形,我想用它们显示的图像创建相同的矩形,如地图,
目前我正在做的是这个 -
我只想像第一个图像一样更改图像,我的消息应该出现在这个矩形框中,下面的小图像应该出现在地图图像中。
这是我当前的代码:
-(UIImage *) drawText:(NSString*) text inImage:(UIImage*)image :(UIImage *)contact_picture
{
UILabel *lblText=[[UILabel alloc]init];
lblText.text=[NSString stringWithFormat:@"%@",text];
lblText.font = [UIFont fontWithName:@"Helvetica-Bold" size:30.0f];
UIFont *font =lblText.font;;
if ([UIScreen instancesRespondToSelector:@selector(scale)]) {
UIGraphicsBeginImageContextWithOptions(CGSizeMake(320.0, 480.0), NO, 0.0f);
} else {
UIGraphicsBeginImageContext(CGSizeMake(320.0, 480.0));
}
CGContextRef context = UIGraphicsGetCurrentContext();
[image drawInRect:CGRectMake(0,0,320.0,480.0)];
[contact_picture drawInRect:CGRectMake(230,295,90,90)];
CGRect rect = CGRectMake(20,120,320, 480);//Set Frame as per your Requirement
CGContextSetRGBFillColor(context, 255, 255, 255, 1);
[text drawInRect:CGRectIntegral(rect) withFont:font];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}