简体   繁体   English

Swift - 滚动视图适合整个屏幕吗?

[英]Swift - Have scroll view fit the entire screen?

My scroll view does not fit the screen entirely.我的滚动视图不完全适合屏幕。 There is a black border at the top and on the left side.顶部和左侧有一个黑色边框。 It looks like this.它看起来像这样。在此处输入图片说明

Here is the code I use to create the 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)

Maybe you will remove "Adjust Scroll View Insets" from UIViewController也许你会从UIViewController删除“调整滚动视图插入”

在此处输入图片说明

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM