Add UIViewController to a scroll view
scrollView.addSubview(tutorialStep.view)
addChildViewController(tutorialStep)
tutorialStep.didMoveToParentViewController(self)
Visual alignment for the views
let views = ["view": view, "page1": page1.view, "page2": page2.view, "page3": page3.view, "page4": page4.view, "page5": page5.view]
let verticalConstraints =
NSLayoutConstraint.constraintsWithVisualFormat(
"V:|[page1(==view)]|", options: nil, metrics: nil, views: views)
NSLayoutConstraint.activateConstraints(verticalConstraints)
let horizontalConstraints =
NSLayoutConstraint.constraintsWithVisualFormat(
"H:|[page1(==view)][page2(==view)][page3(==view)][page4(==view)][page5(==view)]|", options: .AlignAllTop | .AlignAllBottom, metrics: nil, views: views)
NSLayoutConstraint.activateConstraints(horizontalConstraints)
网友评论