2012-09-10 18 views
1

我正在使用UITextView呈現某些文本。我使用下面的代碼來渲染我的主視圖,設置輸出更高的res(我也用相同的因子來縮放所有的子視圖)。iOS設備上的「關閉屏幕」時,UIText View的內容無法呈現

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元素不能正確渲染(大部分只是空白)。

有沒有辦法來覆蓋這個,強制它渲染?

感謝您閱讀

回答

0

結束了使用標籤,只爲渲染。因此,UIText視圖用於在界面中顯示,並用於交互,但它們暫時隱藏並由渲染標籤取代。

2

這樣做:

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(); 
+0

謝謝。我沒有任何麻煩輸出我的整個父視圖的恰好包含任意數量的UIText視圖和UIimage視圖的完美圖像。問題是如上所述縮放視圖之後。不知道是否在你的代碼中有一個修復,但無論如何,讓我知道如果我錯過了它。 – Mrwolfy

+0

檢查已編輯的答案。 –