- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试获取用户看到的整个屏幕的图像。以下代码应该可以工作,但它只能在模拟器中工作。我需要做什么才能让它在运行 iOS 8.1 的设备上运行?
UIView *snapshot = [[UIScreen mainScreen] snapshotViewAfterScreenUpdates:YES];
CGSize outputSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
UIGraphicsBeginImageContextWithOptions(outputSize, NO, 0);
[snapshot drawViewHierarchyInRect:CGRectMake(0.0, 0.0, outputSize.width, outputSize.height) afterScreenUpdates:YES];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
很高兴尝试替代策略,但关键是我想要用户看到它的样子 - 键盘和所有。
干杯
最佳答案
UIGraphicsBeginImageContextWithOptions(CGSizeMake(CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)), NO, 1.0f);
[self.view drawViewHierarchyInRect:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)) afterScreenUpdates:NO];
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
关于ios - UIScreen 上的 snapshotViewAfterScreenUpdates 在设备上提供空白快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27797360/
我正在尝试使用以下代码创建一些复合 UIImage 对象: someImageView.image = [ImageMaker coolImage]; ImageMaker: - (UIImage*)
我正在尝试获取用户看到的整个屏幕的图像。以下代码应该可以工作,但它只能在模拟器中工作。我需要做什么才能让它在运行 iOS 8.1 的设备上运行? UIView *snapshot = [[UIScre
-renderInContext: 自出现以来就被广泛使用,但是它无法渲染 OpenGL 层,AVPreviewLayer(可能是因为它是一种 OpenGL 层)我仍然无法正确渲染 CATiledLa
是否可以从使用 snapshotViewAfterScreenUpdates 创建的 UIView 获取 UIImage ? 从 snapshotViewAfterScreenUpdates 返回的
我注意到运行它会导致 View (或主窗口,不确定)在从 iPhone 5 布局缩放的 iPhone 6/6+ 模拟器上运行时调整片刻(不传递 iPhone 6/6 的启动图像) +): [self.
我正在尝试在我的 iOS 应用程序中获取屏幕截图图像。屏幕截图必须包含屏幕上的所有内容,包括状态栏,因此 this 等解决方案对我不起作用。我尝试了以下方法: override func viewDi
我是一名优秀的程序员,十分优秀!