我已经以编程方式截取了xcode中的滚动视图。但我面临的问题是,我需要截取屏幕截图及其中的当前日期。请帮帮我。
答案 0 :(得分:0)
在拍摄截屏之前,请将一个标签放在当前日期,然后在截屏后将其删除。
答案 1 :(得分:0)
这是您向图像添加文本的方法。以日期为字符串尝试此操作。截取屏幕截图后,将其传递给下面的方法并使用输出图像。为方便起见,修改以下方法。
//Add text to UIImage
-(UIImage *)addText:(UIImage *)img text:(NSString *)text1{
int w = img.size.width;
int h = img.size.height;
//lon = h - lon;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1);
char* text = (char *)[text1 cStringUsingEncoding:NSASCIIStringEncoding];// "05/05/09";
CGContextSelectFont(context, "Arial", 18, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 255, 255, 255, 1);
//rotate text
CGContextSetTextMatrix(context, CGAffineTransformMakeRotation( -M_PI/4 ));
CGContextShowTextAtPoint(context, 4, 52, text, strlen(text));
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
return [UIImage imageWithCGImage:imageMasked];
}
答案 2 :(得分:0)
或者您可以使用EXIF元数据来记录日期(它可能已经在那里)。我猜想图像中的嵌入日期更难以伪造。