有一个 UIImageView
作为属性通过来自另一个 View Controller 的 segue 传递,用户在图像上涂鸦。我无法调整/缩放图像以适应接收 View Controller 中的 UIView
。无论我尝试什么,它都会越过屏幕。
这是我在 viewDidLoad()
中尝试过的一些零成功的例子
incomingImgView?.frame = CGRect(x: 0, y: 0, width: view.bounds.width , height: view.bounds.height)
// incomingImgView?.frame = CGRect(x: 0, y: 0, width: 100 , height: 100)
incomingImgView?.contentMode = .scaleAspectFit
incomingImgView?.clipsToBounds = true
//incomingImgView?.frame = view.bounds
viewContainer.addSubview(incomingImgView!)
// incomingImgView?.image?.scaleImage(toSize: CGSize(width: 100, height: 100))
// incomingImgView?.layoutIfNeeded()
view.layoutIfNeeded()
请试试这个:
incomingImgView?.frame = CGRect(x: 0, y: 0, width: viewContainer.bounds.width , height: viewContainer.bounds.height)
Tôi là một lập trình viên xuất sắc, rất giỏi!