喜 如何在隐藏UIButton后实现NSTimer进行屏幕截图,你能告诉我如何用EXAMPLE实现它。 第一个UIButton必须隐藏,屏幕截图必须占用屏幕 祝你有愉快的一天
答案 0 :(得分:3)
以下是如何获取窗口的屏幕截图:
http://fmwebschool.com/blog/2008/10/01/taking-screenshots-with-the-iphone-sdk/
其余的:
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(count) userInfo:nil repeats:YES];
- (void)count {
counter++;
if (counter == secondsToWait) {
button.alpha = 0;
//Take Screenshot here
}
}
答案 1 :(得分:1)
要在给定时间截取屏幕特定部分的屏幕截图,请使用类似
的内容CGRect screenRect = CGRectMake(0, 0, 200, 200);
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextFillRect(ctx, screenRect);
//you probably need an offset, adjust here
CGContextTranslateCTM(ctx, -20, -20);
[self.view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
//if you want to save this image to the photo album uncomment the next line
//UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
UIGraphicsEndImageContext();
在一个名为takePhoto的方法中包装所有这些,你可以使用NSTimer来触发
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(takePhoto:) userInfo:nil repeats:YES];