Swift UIView在ScrollView中的位置错误

Swift UIView在ScrollView中的位置错误,swift,layout,Swift,Layout,我尝试向scrollview添加4个视图以创建水平分页视图。 但我不明白为什么每个视图之间都有宽度等于每个视图宽度的空白。他们应该靠得很近 walkthroughItems = { let width = UIScreen.mainScreen().bounds.size.width let height = UIScreen.mainScreen().bounds.size.height return [ Walkthro

我尝试向scrollview添加4个视图以创建水平分页视图。 但我不明白为什么每个视图之间都有宽度等于每个视图宽度的空白。他们应该靠得很近

walkthroughItems = {
        let width = UIScreen.mainScreen().bounds.size.width
        let height = UIScreen.mainScreen().bounds.size.height
        return [
            WalkthroughItem0(frame: CGRect(x: 0, y: 0, width: width,height: height)),
            WalkthroughItem1(frame: CGRect(x: width, y: 0, width: width,height: height)),
            WalkthroughItem2(frame: CGRect(x: width * 2, y: 0, width: width,height: height)),
            WalkthroughItem3(frame: CGRect(x: width * 3, y: 0, width: width,height: height))
        ]
    }()
for item in walkthroughItems {
    scrollView.addSubview(item)
}
scrollView.contentSize = CGSize(width: UIScreen.mainScreen().bounds.size.width*4, height: UIScreen.mainScreen().bounds.size.height)
您是否尝试过使用“调试->查看调试->显示图幅”或“调试->查看调试->捕获视图层次结构”来检查您的
演练项中的某些内容是否可能导致此问题?