2012-02-04 64 views
8

我見過幾個應用程序這樣做,我一直在想它是如何完成的。如果您查看Wunderkit應用程序,當它加載某些內容時,會出現一個藍色動畫欄,它可以向下滑動以覆蓋狀態欄,直到完成加載。這是如何完成的?在狀態欄上加載欄?

回答

9

你可以繼承UIWindow。 並設置它windowLevel = UIWindowLevelStatusBar;

代碼:

@interface CHLoadingWindow : UIWindow 

@implementation CHLoadingWindow 
- (id)init 
{ 
    self = [super init]; 
    if (self) { 
    self.windowLevel = UIWindowLevelStatusBar; 
    // then draw your UI 
    } 
    return self; 
} 
@end 

使用它:

CHLoadingWindow *loading = [[CHLoadingWindow alloc] init]; 
[loading makeKeyAndVisible]; 

發現它:

[loading release]; 
loading = nil; 

[[[[UIApplication sharedApplication] windows] objectAtIndex:0] makeKeyWindow]; 
+0

哇感謝!這工作完美:) – 2012-02-04 15:56:18

+0

你能提供更多的解釋嗎?我無法獲得此代碼的工作。 – robhasacamera 2012-07-27 16:22:44