【关于状态栏】
首先, info.plist文件中View controller-based status bar appearance项设为NO。
之前想要将状态栏设置成黑色:
旧方法:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
新方法:
if (@available(iOS 13, *)) {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
} else {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
【APP取消暗黑模式】
info.plist文件中User Interface Style 设置值(string)为Light。这样即便用户设置暗黑模式,APP也不会更改默认的颜色。
【导航栏NavigationItem的边距问题】
https://github.com/spicyShrimp/UINavigation-SXFixSpace
导入这个库后,在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);
}
}