仿淘宝顶部等待状态栏

 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 
有人说:爱上一座城,是因为城里住着某个人,能够与所爱的人在一起,连光阴都是美的。即便粗茶淡饭,修篱种田,只要有你陪伴就好。那么,找一个青山绿水的地方,寻一处幽静的茅舍,或是云水禅心的庭院,那里有晴朗的阳光和静谧的悠然,还有你明媚的笑脸。掬一捧花香在平淡的日子,握着一路相随的暖意,让爱的馨香在柴米油盐中升腾;在一杯茶的温情里,体味生活的诗意;在一碗粥的清淡中,感受生活的浪漫,每天清晨你和阳光都在,便是我的幸福。——春暖花开 《择一城终老,遇一人白首》
原文地址:https://www.cnblogs.com/-Eric-Liu/p/5564124.html