gpt4 book ai didi

ios - UIText View 的内容在 iOS 设备上 "off screen"时不呈现

转载 作者:行者123 更新时间:2023-12-01 16:04:57 25 4
gpt4 key购买 nike

我正在使用 UITextView 来呈现一些文本。我正在使用以下代码将我的主 View 渲染得更大,以将输出设置为更高的分辨率(我还按相同的因子缩放所有 subview )。

    UIGraphicsBeginImageContext(CGSizeMake(ImageView.frame.size.width*4, ImageView.frame.size.height*4));
[outputView setFrame:CGRectMake(outputView.frame.origin.x, outputView.frame.origin.y, outputView.frame.size.width*4, outputView.frame.size.height*4)];
[[outputView layer] renderInContext:UIGraphicsGetCurrentContext()];

在缩放方面工作正常。唯一的问题是 UITextView 元素在“屏幕外”时将无法正确呈现。因此,在没有 *4 比例因子的情况下,一切都可以正常呈现,但是使用它,推离屏幕的 UITextView 元素无法正确呈现(大部分只是空白)。

有没有办法覆盖它,强制它渲染?

感谢阅读

最佳答案

这样做:

  CGAffineTransform newtransform = CGAffineTransformMakeScale(4.0, 4.0);
self.view.transform = newtransform;
CGRect newFrame = CGRectApplyAffineTransform(self.view.frame, newtransform);
//CGSize fittingSize = [yourTextView sizeThatFits:CGSizeZero];
UIGraphicsBeginImageContext(newFrame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImahe *capImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

关于ios - UIText View 的内容在 iOS 设备上 "off screen"时不呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12345261/

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