gpt4 book ai didi

ios - 制作屏幕截图时隐藏按钮 UIGraphicsBeginImageContextWithOptions

转载 作者:行者123 更新时间:2023-11-28 22:05:44 27 4
gpt4 key购买 nike

在使用 UIGraphicsBeginImageContextWithOptions 截屏时,是否有隐藏特定按钮(IBAction)的方法?

我正在使用下面的代码:

 // Define the dimensions of the screenshot you want to take (the entire screen in this case)
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *sourceImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

//now we will position the image, X/Y away from top left corner to get the portion we want
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[sourceImage drawAtPoint:CGPointMake(0, -20)];
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(croppedImage,nil, nil, nil);

谢谢您的回答!

最佳答案

为您 View 上的每个按钮添加 outlet 并设置 Hidden = YES,

否则你可以这样做

for(UIView *v in self.view.subviews){
if([v isKindOfClass:[UIButton class]])
[v setHidden:YES];
}

关于ios - 制作屏幕截图时隐藏按钮 UIGraphicsBeginImageContextWithOptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24057820/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com