2012-10-10 44 views
1

我有一个uiimageview即600x600和uitexview加载到一个200x200的视图。将uiview保存为指定尺寸

我想将此uiview导出为600x600,与uiimageview大小相同。

但是,如果我使用下面的代码,我只能生成400x400的大小,这就是uiview的视网膜大小。

有没有我可以实现这个目标的任何代码?

UIGraphicsBeginImageContextWithOptions(outputView.bounds.size, outputView.opaque, 2); 
[outputView.layer renderInContext:UIGraphicsGetCurrentContext()]; 

UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 

UIGraphicsEndImageContext(); 
+0

你尝试对outputView应用转换吗?即'outputView.transform = CGAffineTransformMakeScale(1.5,1.5);' – mvds

回答

1

您是否尝试过改变视图,你需要什么样的界限?

outputView.bounds = CGRectMake(0,0,600,600); 
UIGraphicsBeginImageContextWithOptions(outputView.bounds.size, outputView.opaque, 2);  [outputView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 
outputView.bound = ... original bounds here ... 

如果内部视图设置为自动调整大小,这应该无缝工作。否则,您也可以更改内部视图的框架。

+0

感谢outputView的工作。我已经将边界应用于'uitextview',但它根本没有改变,有什么想法? – zeropt7

+0

我想你可以缩放文本视图,如果你想要它更大;或者你改变框架和字体大小... – sergio

+0

现在的工作,非常感谢。 – zeropt7