简体   繁体   English

iPhone:如何使用NSTimer隐藏UIButton并拍摄屏幕截图

[英]iPhone: how use NSTimer to hide UIButton and take screen shot

hi how to implement NSTimer to take screen shot after hidding the UIButton,can you tell me how to implement this with EXAMPLE. 您好如何在隐藏UIButton后实现NSTimer进行屏幕截图,您能告诉我如何使用EXAMPLE实现它。 First UIButton has to hide and Screen shot has to take the screen have a nice day 首先UIButton必须隐藏和屏幕截图必须采取屏幕有一个美好的一天

Here's how to take a Screenshot of your Window: 以下是如何获取窗口的屏幕截图:

http://fmwebschool.com/blog/2008/10/01/taking-screenshots-with-the-iphone-sdk/ http://fmwebschool.com/blog/2008/10/01/taking-screenshots-with-the-iphone-sdk/

For the rest: 对于其余的:

[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
}
}

To take a screenshot of a particular section of the screen at a given time use something like this 要在给定时间截取屏幕特定部分的屏幕截图,请使用类似的内容

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();

Wrap all of this up in a method called takePhoto and you can just use NSTimer to trigger 在一个名为takePhoto的方法中包装所有这些,你可以使用NSTimer来触发

[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(takePhoto:) userInfo:nil repeats:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM