我尝试向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)