我的滚动视图不完全适合屏幕。顶部和左侧有黑色边框。它看起来像这样。
以下是我用来创建scrollView的代码:
imageView = UIImageView(image: UIImage(named: "Map 1.png"))
scrollView = UIScrollView(frame: view.bounds)
scrollView.backgroundColor = UIColor.blackColor()
scrollView.contentSize = imageView.bounds.size
scrollView.addSubview(imageView)
view.addSubview(scrollView)
答案 0 :(得分:0)
也许你会删除"调整滚动视图插图"来自UIViewController
答案 1 :(得分:-1)
imageView = UIImageView(image: UIImage(named: "Map 1.png"))
imageView.contentMode = .ScaleToFill
imageView.frame = CGRect(x: 0, y: 0, width: self.scrollView.frame.width , height: self.scrollView.frame.height)
scrollView.contentSize.width = scrollView.frame.width
scrollView.addSubview(imageView)
view.addSubview(scrollView)