首页 > 其他 > 详细

仿淘宝顶部等待状态栏

时间:2016-06-06 16:43:52      阅读:198      评论:0      收藏:0      [点我收藏+]
 1 <pre name="code" class="objc">#import "AppDelegate.h"  
 2   
 3   
 4   
 5 @implementation AppDelegate  
 6   
 7 - (void)dealloc  
 8 {  
 9     [_page release];  
10     [_window release];  
11     [_viewController release];  
12     [super dealloc];  
13 }  
14   
15 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  
16 {  
17     self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];  
18     // Override point for customization after application launch.  
19       
20     self.viewController = [[[UIViewController alloc] init] autorelease];  
21     self.viewController.view.backgroundColor=[UIColor greenColor];  
22     self.window.rootViewController = self.viewController;  
23     [self.window makeKeyAndVisible];  
24       
25       
26     self.page=[[UIPageControl alloc]initWithFrame:CGRectMake(0, 0, 100, 20)];  
27       
28     self.page.backgroundColor=[UIColor clearColor];  
29     self.page.numberOfPages=3;  
30       
31     UIWindow *top_statusbar=[[UIWindow alloc]initWithFrame:CGRectMake(0, 0, 100, 20)];  
32     top_statusbar.center=CGPointMake(160, 10);  
33     [top_statusbar addSubview:self.page];  
34     top_statusbar.backgroundColor=[UIColor blackColor];  
35     [top_statusbar setHidden:NO];  
36     top_statusbar.windowLevel = UIWindowLevelStatusBar + 1.0f;  
37     top_statusbar.alpha=1;  
38       
39     [self.page release];  
40       
41     NSTimer *timer=[NSTimer timerWithTimeInterval:0.2f target:self selector:@selector(pageNumberChanged) userInfo:nil repeats:YES];  
42     [[NSRunLoop mainRunLoop]addTimer:timer forMode:NSDefaultRunLoopMode];  
43       
44       
45     return YES;  
46 }  
47 -(void)pageNumberChanged  
48 {  
49     static int i=0;  
50     i++;  
51     i=i>2?0:i;  
52     self.page.currentPage=i;  
53 }  
54   
55   
56   
57 - (void)applicationWillResignActive:(UIApplication *)application  
58 {  
59     // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.  
60     // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.  
61 }  
62   
63 - (void)applicationDidEnterBackground:(UIApplication *)application  
64 {  
65     // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.   
66     // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.  
67 }  
68   
69 - (void)applicationWillEnterForeground:(UIApplication *)application  
70 {  
71     // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.  
72 }  
73   
74 - (void)applicationDidBecomeActive:(UIApplication *)application  
75 {  
76     // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.  
77 }  
78   
79 - (void)applicationWillTerminate:(UIApplication *)application  
80 {  
81     // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.  
82 }  
83   
84 @end 

 

仿淘宝顶部等待状态栏

原文:http://www.cnblogs.com/-Eric-Liu/p/5564124.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!