iOS13 适配 夜间模式与其他
夜间模式
其他问题:presentViewController
###一 :夜间/深色模式 DarkMode
夜间模式是iOS13的重要更新之一,随之而来的是我们能从系统设置中“显示与亮度”中选择“浅色”、“深色”两种模式,并且可以设置自动切换。(“控制中心”亮度调节中也可直接调节)
已知问题:在系统设置为深色模式时候,无法更改StateBar颜色
如果不想适配深色模式 (1).直接在项目的plist文件中设置 UIUserInterfaceStyle UIUserInterfaceStyleLight
(2).在每个UIViewController或者BaseViewController(如果自己有的话),中设置 if (@available(iOS 13.0, *)){ self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight; }
适配深色模式 首先我们要看一下显示模式的枚举值
typedef NS_ENUM(NSInteger, UIUserInterfaceStyle) {
UIUserInterfaceStyleUnspecified,
UIUserInterfaceStyleLight,
UIUserInterfaceStyleDark,
} API_AVAILABLE(tvos(10.0)) API_AVAILABLE(ios(12.0)) API_UNAVAILABLE(watchos);
当前API还没有提供浅色/深色模式切换时的通知,但是为UIColor添加了新方法: + (UIColor *)colorWithDynamicProvider:(UIColor * (^)(UITraitCollection *))dynamicPr