iOS10~最新系统适配相关

iOS13 适配最新

2019-10-09  本文已影响0人  deeper_iOS

iOS13 适配最新

1、iOS的界面UI变化

暗黑模式下 appStatusBar蜜汁变白、Label变白、cell变黑、Tabbar变蓝

前三种UI问题的话,self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight 强制浅色模式是最快解决方式,尽量不要去info.plist去加Key,容易被拒。

当然如果你想要适配的话嘞

//这是系统颜色的适配
self.label.textColor = [UIColor labelColor];
self.secondLabel.textColor = [UIColor secondaryLabelColor];
self.thirdLabel.textColor = [UIColor tertiaryLabelColor];
self.fourthLabel.textColor = [UIColor quaternaryLabelColor];
图片描述
//这是自定义颜色的适配
到Assets.xcassets下新建一个Color Set后 Appearances选上支持Any和dark,
self.customLabel.textColor = [UIColor colorNamed:@"Color"]; 
//有点像图片的赋值 当然也可以写一个宏
#define EPColor_2F2F2F     [UIColor colorNamed:@"2F2F2F"];
self.customLabel.textColor = EPColor_2F2F2F;

图片的适配跟颜色类似,勾选上就行

这样的话前三个问题就解决掉了,接下来第四种的话

当你push到一个vc,然后pop回去之后,tabbar就会出现系统按钮的蓝色文字,这也是困扰了我一俩小时, 最后 self.tabBar.tintColor = 你的文字颜色; 解决

2、控件的变化

2.1 UITextField 的私有属性 _placeholderLabel 被禁止访问

[self.textField setValue:self.placeholderColor forKeyPath:@"_placeholderLabel.textColor"];崩溃个人猜测不只是textField setValue会崩溃,通过 KVC 方式修改私有属性,有 Crash 风险,谨慎使用!

解决方案:

NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName : self.placeholderColor}]; _textField.attributedPlaceholder = placeholderString;

2.2控制器的 modalPresentationStyle 默认值变了
解决方案:
    控制器 *vc = [[控制器 alloc]init];
    vc.selectedCommunityId = self.arreId;
    UINavigationController * navi = [[UINavigationController alloc]initWithRootViewController: vc];
    navi.navigationBar.barTintColor = [UIColor whiteColor];
//    navi.modalPresentationStyle = UIModalPresentationFullScreen;改成正常跳转,这就看你产品经理喜好了
    [self presentViewController:navi animated:YES completion:nil];
2.3 MPMoviePlayerController禁用了
解决方案:

使用AVKit里面的那套播放器,不细说

2.4 DeviceToken获取方式有变化
NSString *dt = [deviceToken description];
dt = [dt stringByReplacingOccurrencesOfString: @"<" withString: @""];
dt = [dt stringByReplacingOccurrencesOfString: @">" withString: @""];
dt = [dt stringByReplacingOccurrencesOfString: @" " withString: @""];
这段代码运行在 iOS 13 上已经无法获取到准确的DeviceToken字符串了,iOS 13 通过[deviceToken description]获取到的内容已经变了。
解决方案:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
//其实我个人感觉这只是对友盟推送有影响,极光的话,直接` [JPUSHService registerDeviceToken:deviceToken];`就行,本人用的是极光

    if (![deviceToken isKindOfClass:[NSData class]]) return;
    const unsigned *tokenBytes = [deviceToken bytes];
    NSString *hexToken = [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:%@",hexToken);
}
2.5 第三方登录有变化
解决方案:

苹果爸爸强制 如果App中包微信、QQ、微博等三方登录的话,必须加上苹果登录且在第一位!!!
附上官方Demo:点我下载

2.6 LaunchImage 将被弃用

2020年4月份LaunchImage将成为历史

解决方案:

建议尽早替换LanuchSreen,在lanchuScreen上面拖一个imageView,然后约束一下,换上你的图就ok啦 ,我用的是X Max的图,各个机型跑了一下,没啥问题
LaunchScreen是支持AutoLayout+SizeClass的,所以适配各种屏幕都不在话下。

这大概是我升级Xcode 11+iOS 13之后所遇到的问题,如果后续有问题会继续更新,如果有说的不对的地方,欢迎大家批评指正😁
上一篇 下一篇

猜你喜欢

热点阅读