iOS10适配问题及解决方法 新鲜出炉!

2020-01-18 15:45:23于海丽

或者在Xcode里选中当前的target,选择Capabilities,找到Background Modes,打开它,在里面选择对应权限

iOS10,适配

3.UIColor的问题

官方文档中说:大多数core开头的图形框架和AVFoundation都提高了对扩展像素和宽色域色彩空间的支持.通过图形堆栈扩展这种方式比以往支持广色域的显示设备更加容易。现在对UIKit扩展可以在sRGB的色彩空间下工作,性能更好,也可以在更广泛的色域来搭配sRGB颜色.如果你的项目中是通过低级别的api自己实现图形处理的,建议使用sRGB,也就是说在项目中使用了RGB转化颜色的建议转换为使用sRGB,在UIColor类中新增了两个api:


- (UIColor *)initWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);
+ (UIColor *)colorWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);

4.真彩色的显示

真彩色的显示会根据光感应器来自动的调节达到特定环境下显示与性能的平衡效果,如果需要这个功能的话,可以在info.plist里配置(在Source Code模式下):

<key>UIWhitePointAdaptivityStyle</key>
它有五种取值,分别是:


<string>UIWhitePointAdaptivityStyleStandard</string> // 标准模式
<string>UIWhitePointAdaptivityStyleReading</string> // 阅读模式
<string>UIWhitePointAdaptivityStylePhoto</string> // 图片模式
<string>UIWhitePointAdaptivityStyleVideo</string> // 视频模式
<string>UIWhitePointAdaptivityStyleStandard</string> // 游戏模式

也就是说如果你的项目是阅读类的,就选择UIWhitePointAdaptivityStyleReading这个模式,五种模式的显示效果是从上往下递减,也就是说如果你的项目是图片处理类的,你选择的是阅读模式,给选择太好的效果会影响性能.

5.ATS的问题

1.在iOS 9的时候,默认非HTTS的网络是被禁止的,我们可以在info.plist文件中添加NSAppTransportSecurity字典,将NSAllowsArbitraryLoads设置为YES来禁用ATS;
2.从2017年1月1日起,,所有新提交的 app 默认不允许使用NSAllowsArbitraryLoads来绕过ATS的限制,默认情况下你的 app 可以访问加密足够强的(TLS V1.2以上)HTTPS内容;
3.可以选择使用NSExceptionDomains设置白名单的方式对特定的域名开放HTTP内容来通过审核,比如说你的应用集成了第三方的登录分享SDK,可以通过这种方式来做,下面以新浪SDK作为示范(Source Code 模式下):


 <key>NSAppTransportSecurity</key>
 <dict>
 <key>NSExceptionDomains</key>
 <dict>
 <key>sina.cn</key>
 <dict>
 <key>NSThirdPartyExceptionMinimumTLSVersion</key>
 <string>TLSv1.0</string>
 <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
 <false/>
 <key>NSIncludesSubdomains</key>
 <true/>
 </dict>
 <key>weibo.cn</key>
 <dict>
 <key>NSThirdPartyExceptionMinimumTLSVersion</key>
 <string>TLSv1.0</string>
 <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
 <false/>
 <key>NSIncludesSubdomains</key>
 <true/>
 </dict>
 <key>weibo. com</key>
 <dict>
 <key>NSThirdPartyExceptionMinimumTLSVersion</key>
 <string>TLSv1.0</string>
 <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
 <false/>
 <key>NSIncludesSubdomains</key>
 <true/>
 </dict>
 <key>sinaimg.cn</key>
 <dict>
 <key>NSThirdPartyExceptionMinimumTLSVersion</key>
 <string>TLSv1.0</string>
 <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
 <false/>
 <key>NSIncludesSubdomains</key>
 <true/>
 </dict>
 <key>sinajs.cn</key>
 <dict>
 <key>NSThirdPartyExceptionMinimumTLSVersion</key>
 <string>TLSv1.0</string>
 <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
 <false/>
 <key>NSIncludesSubdomains</key>
 <true/>
 </dict>
 <key>sina.com.cn</key>
 <dict>
 <key>NSThirdPartyExceptionMinimumTLSVersion</key>
 <string>TLSv1.0</string>
 <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
 <false/>
 <key>NSIncludesSubdomains</key>
 <true/>
 </dict>
 </dict>
 </dict>