我正在尝试使图像适合屏幕宽度 - 使用UIScrollView中的图像:
myImageView = UIImageView(image: UIImage(named: "image.png"))
scrollView = UIScrollView(frame: view.bounds)
let w = myImageView.bounds.width
let h = myImageView.bounds.height
let r = CGRect(x: 0, y: 0, width: w, height: h)
scrollView.zoomToRect(r, animated: false)
scrollView.delegate = self
scrollView.addSubview(myImageView)
view.addSubview(scrollView)
你能吗?
答案 0 :(得分:0)
myImageView = UIImageView(image: UIImage(named: "image.png"))
myImageView.frame = view.bounds
myImageView.contentMode = .ScaleAspectFill
view.addSubview(myImageView)