天天看點

UI基礎__UIApplication/系統中常見的檔案

UIApplication常見設定

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    // 獲得app對象
    UIApplication *app = [UIApplication sharedApplication];
//    // 顯示菊花
    app.networkActivityIndicatorVisible = YES;

   app.statusBarStyle = UIStatusBarStyleLightContent;
    app.statusBarHidden = YES;

   [app setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
   [app setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
    // NSURL組成部分
    // 協定頭://主機域名/資源路徑
    [app openURL:[NSURL URLWithString:@"http://www.baidu.com/"]];

}
           

狀态欄

// 在iOS7.0之後,狀态欄樣式預設交給控制器管理,在iOS7.0之前是由UIApplication對象管理

/**
 *  是否隐藏狀态欄
 */
- (BOOL)prefersStatusBarHidden {
    return YES;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
           

bageValue設定

//自定義方法,實作app圖示右上角顯示數字
- (void)applicationBageValue {
    // 獲得app對象
    UIApplication *app = [UIApplication sharedApplication];
    // 設定應用圖示右上角顯示是數字
    // 在iOS8.0之後,設定圖示數字需要得到使用者允許。
    if ([[UIDevice currentDevice].systemVersion doubleValue] >= ) {
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
        [app registerUserNotificationSettings:settings];
    }
    app.applicationIconBadgeNumber = ;
}
           

pch檔案

.pch檔案,使用的時候需要配置,在“Build Settings”裡面“Prefix Header”填寫路徑:

$(SRCROOT)/項目名/***.pch

注:将

Precompile Prefix Header

為YES,預編譯後的pch檔案會被緩存起來,可以提高編譯速度

#ifndef PrefixHeader_pch
#define PrefixHeader_pch

#import "UMMobClick/MobClick.h"

#endif /* PrefixHeader_pch */