一、模态视图弹出方式改变
/*
Defines the presentation style that will be used for this view controller when it is presented modally. Set this property on the view controller to be presented, not the presenter.
If this property has been set to UIModalPresentationAutomatic, reading it will always return a concrete presentation style. By default UIViewController resolves UIModalPresentationAutomatic to UIModalPresentationPageSheet, but system-provided subclasses may resolve UIModalPresentationAutomatic to other concrete presentation styles. Participation in the resolution of UIModalPresentationAutomatic is reserved for system-provided view controllers.
Defaults to UIModalPresentationAutomatic on iOS starting in iOS 13.0, and UIModalPresentationFullScreen on previous versions. Defaults to UIModalPresentationFullScreen on all other platforms.
*/
@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle API_AVAILABLE(ios(3.2));
就是控制器的modalPresentationStyle属性默认值发生了变化,在iOS13后,系统新添加了一个属性枚举值
新的交互方式默认为下拉dismiss,且导航栏会留白空出;
如果需要点击取消按钮才消失界面的,需要适配;
如果项目中页面高度全部是屏幕尺寸,那么多出来的导航栏高度就会有问题。
如果回到以前的默认值,
//iOS8以上 self为目标控制器
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
//iOS8以下
self.modalPresentationStyle = UIModalPresentationFullScreen;
//如果是UINavigationController为根控制器
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchViewController];
nav.modalPresentationStyle = UIModalPresentationOverFullScreen;
二、私有方法 KVC 不允许使用
iOS13后不再允许valueForKey、setValue:forKey:
等方法获取或设置私有属性,虽然编译可以通过,但是在运行时会直接崩溃或不起作用。
👇下面的方法都没有用了哦
// UITextField 的 _placeholderLabel
[textField setValue:[UIColor blackColor] forKeyPath:@"_placeholderLabel.textColor"];
// UISearchBar 的 _searchField
[searchBar valueForKey:@"_searchField"];
UITextField有一个attributedPlaceholder
属性,占位符富文本,和UILabel等控件的富文本设置一样,可以设置文字颜色,尺寸等。
UITextField *textField = [[UITextField alloc]init];
textField.placeholder = @"我是占位符哦~";
[self.view addSubview:textField];
NSMutableAttributedString *attribute_placeholder = [[NSMutableAttributedString alloc]initWithString:textField.placeholder];
[attribute_placeholder addAttribute:NSForegroundColorAttributeName
value:[UIColor colorWithWhite:1 alpha:0.2]
range:NSMakeRange(0, textField.placeholder.length)];
[attribute_placeholder addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:14]
range:NSMakeRange(0, textField.placeholder.length)];
[searchField setAttributedPlaceholder:attribute_placeholder];
三、searchBar设置textField问题
我们不用再用kvc获取UISearchBar的textField了,因为,iOS13中系统将searchTextField
属性暴露出来了,不再是私有属性了,你可以直接调用。
UITextField *searchField = _searchBar.searchTextField;
注意:以上写法在iOS13以下手机运行会崩溃,所以,暂时要写成两种情况的写法,iOS13依然沿用之前的旧写法。
用[[[UIDevice currentDevice] systemVersion] doubleValue] >= 13.0
加以区分
四、苹果登录 Sign In with Apple
关于苹果登录,如果应用没有使用第三方登录,可以不用添加,如果已经使用了第三方登录(比如微信、QQ、微博等),就必须要加上苹果登录,且要放在最前面。
五、[_LSDefaults sharedInstance]崩溃
遇到'+[_LSDefaults sharedInstance]: unrecognized selector sent to class 0x1dd8f5d40'
崩溃问题,可以尝试~pod update
pod库,暂时可以解决问题。