0
这是同步我的应用程序,我想是我想要显示的图像作为联系人图片和消息像文字下方透明的矩形,我想创建图像相同的矩形,他们已经表现出像地图,
目前我在做什么是这样的 -
我只是想改变像第一图像的图像,我消息应该出现在这个矩形框和下面的小图像像地图图像。
这里是我当前的代码:
-(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;
}
那么什么是你的问题,只是如何让透明的黑色矩形? – Jing
如果是这样,使用UIKit更容易作为您的最后一个问题。不需要使用Quartz。只需使用UILable并设置其背景色,如UIColor * color = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5]; – Jing
我想要与第一张图像相同的矩形。怎么做 ? – krish