仿淘宝顶部等待状态栏

 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值