gpt4 book ai didi

ios - Objective C ScrollView 屏幕截图在 ios 13 中存在问题

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

在 ios 13 之前运行良好的代码在 ios 13 中出现问题。下面的代码是获取与整个 ScrollView 的屏幕截图相同的图像的代码。

    UIGraphicsBeginImageContext(scrollview.contentSize);

CGPoint savedContentOffset = scrollview.contentOffset;
CGRect savedFrame = scrollview.frame;

scrollview.contentOffset = CGPointZero;
scrollview.frame = CGRectMake(0, 0, scrollview.contentSize.width, scrollview.contentSize.height);

[scrollview.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();

scrollview.contentOffset = savedContentOffset;
scrollview.frame = savedFrame;

UIGraphicsEndImageContext();

但是当我在 ios 13 中运行该代码时,底部部分看起来被截断了。从滚动开始,iPhone 将正常图像显示到屏幕底部,但底部不可见。

最佳答案

我找到了问题的答案。问题是框​​架没有改变。

scrollview.frame = CGRectMake(0, 0, scrollview.contentSize.width,     scrollview.contentSize.height);

而不是使用

scrollview.layer.frame = CGRectMake(0, 0, scrollview.contentSize.width, scrollview.contentSize.height);

关于ios - Objective C ScrollView 屏幕截图在 ios 13 中存在问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58517310/

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