【问题标题】:Converting UIView to UIImage gives poor quality [duplicate]将 UIView 转换为 UIImage 质量很差[重复]
【发布时间】:2013-08-16 06:13:08
【问题描述】:

我正在使用以下代码将 UIView 捕获为 UIImage 并将其保存在 Docs Dir 中。

- (UIImage *) imageWithView:(UIView *)view
{
    UIGraphicsBeginImageContext(view.bounds.size);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;
}

UIImage 保存成功。但是分辨率很差。请参阅下图以供参考。如何确保保留原图的分辨率?

【问题讨论】:

标签: iphone uiview uiimage resolution


【解决方案1】:

使用以下代码捕获整个视图的图像:-

 UIGraphicsBeginImageContext(view.frame.size); 

【讨论】:

  • 对不起老兄...这似乎不起作用:(分辨率仍然浪费。
猜你喜欢
  • 1970-01-01
  • 2018-01-09
  • 2011-07-25
  • 2012-12-25
  • 2017-03-03
  • 2018-10-16
  • 1970-01-01
  • 1970-01-01
  • 2016-12-10
相关资源
最近更新 更多