2

我设置了一个屏幕截图按钮,以便我可以捕获整个视图控制器(我的状态栏和导航栏除外)并将该图像输入到相机胶卷。唯一的问题是,如果我尝试从我的相机胶卷打印此图像,它打印的图像只有页面大小的 1/4。图像太小,我需要它是 850 x 1100(“字母”大小)。

您如何将我的屏幕截图编码为打印,而不是保存到相机胶卷 - 并专门打印 850 x 1100(信纸大小)。

这是我的屏幕截图的样子:

///////// screenshot save
@IBAction func buttonAction(_ sender: UIButton) {


//partial screenshot function
let top: CGFloat = 46
let bottom: CGFloat = 0
let size = CGSize(width: view.frame.size.width, height: view.frame.size.height - top - bottom)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
let context = UIGraphicsGetCurrentContext()!
context.translateBy(x: 0, y: -top)
view.layer.render(in: context)
let snapshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

//Save photo to camera roll
UIImageWriteToSavedPhotosAlbum(snapshot!, nil, nil, nil)

//Flash screen when photo is saved
let shutterView = UIView(frame: view.frame)
shutterView.backgroundColor = UIColor.black
view.addSubview(shutterView)
UIView.animate(withDuration: 0.3, animations: {
    shutterView.alpha = 0
}, completion: { (_) in
    shutterView.removeFromSuperview()
})


}

请帮忙!我不知道我在做什么。有人提到我应该实现 UIPrintInteractionController,但我不知道如何实现,因为我对编程很陌生。

4

0 回答 0