Snapchat은 UIScrollView를 광범위하게 사용합니다.
let convVC = self.storyboard!.instantiateViewControllerWithIdentifier("storyboardIdentifier") as! UIViewController
view1.addSubview(convVC.view)
self.addChildViewController(convVC)
스크롤 뷰 앞으로 방법
있습니다 : 스토리 보드 사용은 다음 코드를 사용에서
override func viewDidLoad() {
super.viewDidLoad()
var scrollView = UIScrollView(frame: CGRectMake(0, 0, self.view.bounds.width, self.view.bounds.height))
scrollView.contentSize = CGSizeMake(self.view.bounds.width*3, self.view.bounds.height)
scrollView.pagingEnabled=true
self.view.addSubview(scrollView)
var view1 = UIView(frame: CGRectMake(0, 0, self.view.bounds.width, self.view.bounds.height))
view1.backgroundColor=UIColor.blueColor()
scrollView.addSubview(view1)
//Add View controller 1 to view1
var view2 = UIView(frame: CGRectMake(self.view.bounds.width, 0, self.view.bounds.width, self.view.bounds.height))
view2.backgroundColor=UIColor.greenColor()
scrollView2.addSubview(view2)
//Add view controller 2 to view2
var view3 = UIView(frame: CGRectMake(2*view.bounds.width, 0, self.view.bounds.width, self.view.bounds.height))
view3.backgroundColor=UIColor.orangeColor()
scrollView.addSubview(view3)
//Add view controller 3 to view3
}
는 뷰 컨트롤러를 추가하려면 예를 들면 다음과 같습니다