相关疑难解决方法(0)

如何在不损失视网膜显示质量的情况下将UIView捕获到UIImage

我的代码适用于普通设备,但在视网膜设备上会产生模糊图像.

有人知道我的问题的解决方案吗?

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

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;
}
Run Code Online (Sandbox Code Playgroud)

image-capture scale uikit uiimage retina-display

293
推荐指数
9
解决办法
15万
查看次数

如何在Swift中使用全屏截图?

我发现了这段代码:

func screenShotMethod() {
    //Create the UIImage
    UIGraphicsBeginImageContext(view.frame.size)
    view.layer.renderInContext(UIGraphicsGetCurrentContext())
    let image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    //Save it to the camera roll
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
}
Run Code Online (Sandbox Code Playgroud)

我需要做些什么才能将所有其他元素(如导航栏)添加到屏幕截图中?

screenshot uiimage ios swift

64
推荐指数
6
解决办法
6万
查看次数

标签 统计

uiimage ×2

image-capture ×1

ios ×1

retina-display ×1

scale ×1

screenshot ×1

swift ×1

uikit ×1