有一個UIImageView
作爲屬性通過從其他用戶在圖像上塗寫的視圖控制器的segue傳遞。我無法在接收視圖控制器中適合/縮放圖像以適應UIView
。無論我嘗試什麼,它都會在屏幕上顯示。調整UIImageView的大小以適應屏幕
這裏有一些我與零次的成功嘗試在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()
爲什麼你在兩個UIViews之間傳遞UIImageView?爲什麼不只是傳遞一個UIImage,讓每個UIView按照你想要的方式進行尺寸調整? – dfd
@CodeTree請不要做那樣的事情。傳遞數據 - 而不是接口。 –