标签:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import UIKit @UIApplicationMain class AppDelegate : UIResponder , UIApplicationDelegate { var window: UIWindow ? func application(application: UIApplication , didFinishLaunchingWithOptions launchOptions: [ NSObject : AnyObject ]?) -> Bool { // Override point for customization after application launch. //增加标识,用于判断是否是第一次启动应用... if (!( NSUserDefaults .standardUserDefaults().boolForKey( "everLaunched" ))) { NSUserDefaults .standardUserDefaults().setBool( true , forKey: "everLaunched" ) var guideViewController = GuideViewController () self .window!.rootViewController=guideViewController; println ( "guideview launched!" ) } return true } func applicationWillResignActive(application: UIApplication ) { } func applicationDidEnterBackground(application: UIApplication ) { } func applicationWillEnterForeground(application: UIApplication ) { } func applicationDidBecomeActive(application: UIApplication ) { } func applicationWillTerminate(application: UIApplication ) { } } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import UIKit class GuideViewController : UIViewController , UIScrollViewDelegate { var numOfPages = 3 override func viewDidLoad() { var frame = self .view.bounds //scrollView的初始化 var scrollView= UIScrollView () scrollView.frame= self .view.bounds scrollView.delegate = self //为了能让内容横向滚动,设置横向内容宽度为3个页面的宽度总和 scrollView.contentSize= CGSizeMake (frame.size.width* CGFloat (numOfPages),frame.size.height) println ( "\(frame.size.width*CGFloat(numOfPages)),\(frame.size.height)" ) scrollView.pagingEnabled= true scrollView.showsHorizontalScrollIndicator= false scrollView.showsVerticalScrollIndicator= false scrollView.scrollsToTop= false for i in 0..<numOfPages{ var imgfile = "jianjie\(Int(i+1)).png" println (imgfile) var image = UIImage (named: "\(imgfile)" ) var imgView = UIImageView (image: image) imgView.frame= CGRectMake (frame.size.width* CGFloat (i), CGFloat (0), frame.size.width,frame.size.height) scrollView.addSubview(imgView) } scrollView.contentOffset = CGPointZero self .view.addSubview(scrollView) } func scrollViewDidScroll(scrollView: UIScrollView !) { println ( "scrolled:\(scrollView.contentOffset)" ) var twidth = CGFloat (numOfPages-1) * self .view.bounds.size.width if (scrollView.contentOffset.x > twidth) { var mainStoryboard = UIStoryboard (name: "Main" , bundle: nil ) var viewController = mainStoryboard.instantiateInitialViewController() as UIViewController self .presentViewController(viewController, animated: true , completion: nil ) } } } |
标签:
原文地址:http://www.cnblogs.com/Free-Thinker/p/4838417.html