//
// ViewController.swift
// PMBUI
//
// Created by ScofieldRoger on 3/4/15.
// Copyright (c) 2015 ScofieldRoger. All rights reserved.
//
importUIKit
classViewController:UIViewController,UIScrollViewDelegate{
overridefuncviewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
scollView1.contentSize=CGSize(width:320*4, height:568)
self.view.backgroundColor=UIColor.redColor()
scollView1.delegate=self
varview2 =UIView(frame:CGRect(x:0*320, y:0, width:320, height:568))
view2.backgroundColor=UIColor.yellowColor()
scollView1.addSubview(view2)
varview3 =UIView(frame:CGRect(x:1*320, y:0, width:320, height:568))
view3.backgroundColor=UIColor.blueColor()
scollView1.addSubview(view3)
varview4 =UIView(frame:CGRect(x:2*320, y:0, width:320, height:568))
view4.backgroundColor=UIColor.greenColor()
scollView1.addSubview(view4)
scollView1.delegate=self
}
overridefuncdidReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBOutletweakvarscollView1:UIScrollView!
@IBOutletweakvarpageControl1:UIPageControl!
funcscrollViewDidScroll(scrollView:UIScrollView) {
varcurrentPageOfScrollView = (scollView1.contentOffset.x/320)
pageControl1.currentPage=Int(currentPageOfScrollView)
}
@IBActionfuncpageControl(sender:UIPageControl) {
varcurPage = (pageControl1.currentPage) *320
scollView1.scrollRectToVisible(CGRect(x: curPage, y:0, width:320, height:568), animated:true)
}
}