gpt4 book ai didi

ios - 在包含 UIDatePicker 的 View 上拍摄快照

转载 作者:行者123 更新时间:2023-11-29 12:35:22 24 4
gpt4 key购买 nike

我使用下面的代码拍摄 View 快照。它适用于大多数情况,但不适用于包含 UIDatePicker 的 View 。

    UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

观点是:

enter image description here

它生成的图像看起来很奇怪:

enter image description here

谁能告诉我为什么会发生这种情况以及如何拍摄包含 UIDatePicker 的 View 的快照。

提前致谢。

最佳答案

不使用图层的 renderInContext 方法,而是使用这个:

[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];

关于ios - 在包含 UIDatePicker 的 View 上拍摄快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26503067/

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