我给UIImageView
下了一个大头针,因为我先拿了一个UIView
。在UIView
中,我有用于缩放功能的UIScrollview
,然后在UIScrollview
中,我有用于我的UIImageView
的缩放功能。
UIView
UIScrollView
UIImageView
但缩放图像后,我想要完整的图像,而不是只缩放图像的一部分,我使用UIView
将引脚图像和主图像合并在一张图像中。
我试过一些代码,让我演示给你看
正如你可以看到我的代码,我正在获取主UIView
的帧,它被转换为图像,然后我将该帧传递给另一个ViewController
,然后我将其设置为UIView
,但它不能设置,我检查我的帧如预期的那样完美,但我仍然只能得到图像的缩放部分。
因为我在下面提到了我的代码,我不清楚为什么我不能设置框架,所以请有人帮助我
@IBAction func btnTapped(_ sender: UIButton) {
let VC = self.storyboard?.instantiateViewController(withIdentifier: "ThirdViewController") as! ThirdViewController
let image = conImgView.getImage()
VC.image = image
if let frame = conImgView.superview?.convert(conImgView.frame, to: nil) {
print(frame)
VC.frame1 = frame
}
self.present(VC, animated: true, completion: nil)
}
我想要完整的图像缩放后,不仅是部分放大排序,我想要完整的图像,当我重定向到另一个ViewController上的按钮点击。
发布于 2019-05-08 12:11:46
如果要将图像设置为完全显示,则意味着将contentMode
设置为scaleAspectFit
。
let yourImageView : UIImageView = UIImageView()
yourImageView.frame = customFrame
yourImageView.contentMode = .scaleAspectFit
https://stackoverflow.com/questions/56039934
复制相似问题