iOS13 適配筆記

【關(guān)于狀態(tài)欄】

首先, info.plist文件中View controller-based status bar appearance項(xiàng)設(shè)為NO。

之前想要將狀態(tài)欄設(shè)置成黑色:
舊方法:

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; 

新方法:

if (@available(iOS 13, *)) {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
    } else {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    }

【APP取消暗黑模式】

info.plist文件中User Interface Style 設(shè)置值(string)為Light。這樣即便用戶設(shè)置暗黑模式,APP也不會(huì)更改默認(rèn)的顏色。

【導(dǎo)航欄NavigationItem的邊距問題】

https://github.com/spicyShrimp/UINavigation-SXFixSpace
導(dǎo)入這個(gè)庫后,在BaseViewController使用方法:

[UINavigationConfig shared].sx_defaultFixSpace = 8.0f;

【iOS 13獲取Devicetoken的方法改變】

示例代碼:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
    NSString *token;
    
    if (@available(iOS 13, *)) {
        if (![deviceToken isKindOfClass:[NSData class]]) return;
        const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];
        token = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
        ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
        ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
        ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
        NSLog(@"deviceToken:%@",token);
    } else {
        token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<" withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString:@" " withString:@""];
        NSLog(@"deviceToken:%@",token);
    }
  
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容