使用苹果私有API
- 获取UISearchBar的_searchField对象
//iOS 13之前:
UITextField *searchField = [searchBar valueForKey:@"_searchField"];//在iOS 13上运行直接Crash
//iOS 13之后应修改成:
UITextField *searchField;
//这里要注意searchTextField属性时从13.0才开始有的,所以针对其他iOS版本,需要做一个容错
if(@available(iOS 13.0, *)){
searchField = searchBar.searchTextField;
}else{
searchField = [searchBar valueForKey:@"_searchField"];
}
- 改UITextField的placeholder的color属性
//iOS 13之前:
[textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
//iOS 13之后应修改成:
NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName:[UIColor grayColor]}];
textField.attributedPlaceholder = placeholderString;
UITabBar切换后文字颜色异常
解决办法:
//这里要注意unselectedItemTintColor属性时从10.0才开始有的,所以针对其他iOS版本,需要做一个容错
if(@available(iOS 10.0, *)){
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor grayColor]];
}
模态交互
若你是使用presentViewController进行跳转的话会发现默认不是全屏了,并且下拉返回之前页面时还会有偶发性的Crash,这里需要修改modalPresentationStyle属性
VC2.modalPresentationStyle = UIModalPresentationFullScreen;
[VC1 presentViewController:VC2 animated:YES completion:nil];
深色模式
iOS 13的几大卖点之一,但是若要适配起来却非常麻烦,开发的工作量着实不小,有两个解决办法:
- 配置info.plist的UserInterfaceStyle为Light,暴力搞定;
- 老老实实适配,在所有需要设置颜色的地方逐一做判断,并且对应xcassets素材也要修改。
蓝牙隐私Privacy的Key有变化
我们都知道,如果App需要连接蓝牙硬件设备,必须配置info.plist的NSBluetoothPeripheralUsageDescription:
Privacy - Bluetooth Peripheral Usage Description
iOS 13之后,也就是你的Xcode上Deployment Target为13.0+时,需要替换为NSBluetoothAlwaysUsageDescription
Privacy - Bluetooth Always Usage Description
若不更换,在提交构App Store Connect构建版本处理阶段就会被打回,没办法提交审核 - -!
导航栏UIBarButtonItem按钮位置偏移问题
见Git:https://github.com/spicyShrimp/UINavigation-SXFixSpace
可通过修改sx_defaultFixSpace属性来设置按钮偏移的距离,在需要设置导航栏按钮的地方,使用:
//文字按钮
self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:action title:@"取消"];;
//图片按钮
self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:action image:[UIImage imageNamed:@"返回"]];
LaunchImage Deprecated
在Project -> Launch Screen File配置中,以前可以指定Assets.xcassets中的LaunchImage作为启动图片
升级至Xcode 11+后系统会默认指定LaunchScreen.storyboard作为启动页,修改上述参数已无效
获取keyWindow的API
UIWindow *window = [[UIApplication sharedApplication].keyWindow];//iOS 13之前
UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];//iOS 13之后keywindow被废弃
Universal Links
UIWebView Deprecated
欢迎各路大神评论/私信小弟补充
如果本文对你有所帮助,记得点个赞哈
网友评论