1、关闭暗黑模式 ,如果没有适配暗黑模式,在暗黑模式下会很丑
在Info.plist文件添加
User Interface Style -> Light
关闭暗黑模式
2、 报错
-
library not found for -lstdc++.6.0.9
解决:用大佬写的脚本 https://github.com/devdawei/libstdc- -
[_LSDefaults sharedInstance]: unrecognized selector sent to class
解决:友盟iOS13报错
3、 presentViewController适配
- 原因是iOS 13 多了一个新的枚举类型 UIModalPresentationAutomatic,并且是modalPresentationStyle的默认值。
UIModalPresentationAutomatic实际是表现是在 iOS 13的设备上被映射成UIModalPresentationPageSheet。
但是需要注意一点PageSheet 与 FullScreen 生命周期并不相同 FullScreen会走完整的生命周期
,PageSheet因为父视图并没有完全消失,所以viewWillDisappear及viewWillAppear并不会走,
如果这些方法里有一些处理,还是换个方式,或者用FullScreen
一句话全局适配,摘自 简书猫爪
采用分类的形式,给 UIViewController 增加一个分类,写入方法
//Objective-C, 直接写在 .m 中
@implementation UIViewController (iOS13)
- (UIModalPresentationStyle)modalPresentationStyle{
return UIModalPresentationFullScreen;
}
@end
4、 私有API被封禁(KVC限制),禁止访问
SearchBar
if ([[[UIDevice currentDevice]systemVersion] floatValue] >=13.0) {
searchField = _vSearchBar.searchTextField;
}else{
searchField = [self valueForKey:@"_searchField"];
}
修改TextFiled的占位符字体大小以及颜色
[_textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[_textField setValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];
替换成
_textField.attributedPlaceholder = [[NSAttributedString alloc]
initWithString:@"姓名" attributes:@{NSFontAttributeName:
[UIFont systemFontOfSize:14]
,NSForegroundColorAttributeName:[UIColor redColor]}];
5、UI调整
- UISegmentedControl 修改选择背景色
iOS13中 ,UISegmentedControl默认样式变为白底黑字
if (@available(iOS 13.0, *)) {
_segmented.selectedSegmentTintColor = Stock_Red;
} else {
_segmented.tintColor = Stock_Red;
}
- webview 全部要用WKWebview替换
6、新增SceneDelegate 适配
作用:据说为iPad的多进程准备的
1.方案 不需要适配ipad的应用,直接删掉
- 删除
SceneDelegate
的文件 - 删除
AppDelegate
中关于SceneDelegate
的函数 - 删除
info.plist
中的Application Scene Manifest
选项 - 在
AppDelegate
中添加window
属性
- 要用到ipad的多线程的适配
-
只有iOS 13 后才启用有
SceneDelegate
及相关函数,@available(iOS 13.0, *)
-
SceneDelegate 代码
@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
//需要用到多线程的时候
guard let windowScene = (scene as? UIWindowScene) else { return }
let nav = YHNavigationController.init(rootViewController: HomeViewController())
nav.view.backgroundColor = UIColor.white
window = UIWindow.init(windowScene: windowScene)
window?.rootViewController = nav
window?.makeKeyAndVisible()
}
}
- AppDelegate 代码
// MARK: UISceneSession Lifecycle
//使用 @available(iOS 13.0, *)进行判断,如果系统没到达13.0的话就不启用该段代码。
@available(iOS 13.0, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
@available(iOS 13.0, *)
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
网友评论