美文网首页
ios13适配不断更新

ios13适配不断更新

作者: 深圳一匹狼 | 来源:发表于2019-11-06 17:46 被阅读0次

1.     暗黑模式

iOS13使用暗黑模式时,UIView默认背景色会变成暗黑色。适配暗黑模式的工作量较大,改为强制使用正常模式。

处理方案:在plist文件中增加配置项UIUserInterfaceStyle,值为Light。

2.    UITextField 的私有属性 _placeholderLabel 被禁止访问了

[self.textField setValue:self.placeholderColor forKeyPath:@"_placeholderLabel.textColor"];

居然崩溃了,错误信息如下

'Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug'

解决方案:

UITextField有个attributedPlaceholder的属性,我们可以自定义这个富文本来达到我们需要的结果。 

 NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:_iphoneTextField.placeholder attributes:@{NSForegroundColorAttributeName : kTextColor}];

_iphoneTextField.attributedPlaceholder= placeholderString;

iOS 13 通过 KVC 方式修改私有属性,有 Crash 风险,谨慎使用!并不是所有KVC都会Crash,要尝试!

3. 使用 UISearchDisplayController 导致崩溃

在 iOS 8 之前,我们在 UITableView 上添加搜索框需要使用 UISearchBar + UISearchDisplayController 的组合方式,而在 iOS 8 之后,苹果就已经推出了 UISearchController 来代替这个组合方式。在 iOS 13 中,如果还继续使用 UISearchDisplayController 会直接导致崩溃

4.

控制器的 modalPresentationStyle 默认值变了

查阅了下 UIModalPresentationStyle枚举定义,赫然发现iOS 13新加了一个枚举值:typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {    UIModalPresentationFullScreen = 0,    UIModalPresentationPageSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),    UIModalPresentationFormSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),    UIModalPresentationCurrentContext API_AVAILABLE(ios(3.2)),    UIModalPresentationCustom API_AVAILABLE(ios(7.0)),    UIModalPresentationOverFullScreen API_AVAILABLE(ios(8.0)),    UIModalPresentationOverCurrentContext API_AVAILABLE(ios(8.0)),    UIModalPresentationPopover API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(tvos),    UIModalPresentationBlurOverFullScreen API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios) API_UNAVAILABLE(watchos),    UIModalPresentationNone API_AVAILABLE(ios(7.0)) = -1,    UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2,};

解决方案

如果你完全接受苹果的这个默认效果,那就不需要去修改任何代码。

如果,你原来就比较细心,已经设置了modalPresentationStyle的值,那你也不会有这个影响。

对于想要找回原来默认交互的同学,直接设置如下即可:

在presentViewController之前加入这个代码

[self presentViewController:nav animated:YES completion:nil];

nav.modalPresentationStyle = UIModalPresentationFullScreen;

相关文章

  • iOS13 适配问题 看这一篇就够了

    技术参考: apple login IOS13适配-详细 iOS 13 适配(持续更新中) iOS13适配 掘金 ...

  • iOS 13适配

    技术参考: apple login IOS13适配-详细 iOS 13 适配(持续更新中) iOS13适配 掘金 ...

  • ios13适配不断更新

    1. 暗黑模式 iOS13使用暗黑模式时,UIView默认背景色会变成暗黑色。适配暗黑模式的工作量较大,改为强制使...

  • 暗黑模式开发

    iOS13暗黑模式适配(项目开发版) iOS 13 DarkMode 暗黑模式 IOS 暗黑模式适配---基础适配

  • iOS13适配更新总结

    前言: iOS13的API的变动和适配问题,我从新特性适配、API 适配、方法弃用、工程适配、SDK 适配、其他问...

  • iOS13适配研究

    iOS13今年秋季会发布,最近深入研究了下公司APP适配iOS13的注意点,适配如下。 1.由于Xcode10移除...

  • iOS13适配

    参考: iOS13 适配踩坑 - 持续更新 iOS 13 适配要点总结 iOS 13 适配要点总结 1、prese...

  • iOS13适配(更新中)

    对于iOS13适配汇总以及遇到的问题注意:以下适配内容,必须适配的会以"必须"标出 1. Dark Model(必...

  • 关于WRNavigationBar iOS12、iOS13导航栏

    集成WRNavigationBar 适配iOS12 iOS13导航栏问题 在修复iOS13下在iPhone11机型...

  • 关于WRNavigationBar iOS12、iOS13导航栏

    集成WRNavigationBar 适配iOS12 iOS13导航栏问题 在修复iOS13下在iPhone11机型...

网友评论

      本文标题:ios13适配不断更新

      本文链接:https://www.haomeiwen.com/subject/kxvgvctx.html