【關(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);
}
}