[英]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.