iOS13.png
一、模態(tài)視圖彈出方式改變
/*
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屬性默認(rèn)值發(fā)生了變化邮旷,在iOS13后懦尝,系統(tǒng)新添加了一個(gè)屬性枚舉值
UIModalPresentationStyle枚舉值.png
新的交互方式默認(rèn)為下拉dismiss累舷,且導(dǎo)航欄會(huì)留白空出浩考;
如果需要點(diǎn)擊取消按鈕才消失界面的,需要適配被盈;
如果項(xiàng)目中頁面高度全部是屏幕尺寸析孽,那么多出來的導(dǎo)航欄高度就會(huì)有問題。
如果回到以前的默認(rèn)值害捕,
//iOS8以上 self為目標(biāo)控制器
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
//iOS8以下
self.modalPresentationStyle = UIModalPresentationFullScreen;
//如果是UINavigationController為根控制器
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchViewController];
nav.modalPresentationStyle = UIModalPresentationOverFullScreen;
二绿淋、私有方法 KVC 不允許使用
iOS13后不再允許valueForKey、setValue:forKey:
等方法獲取或設(shè)置私有屬性尝盼,雖然編譯可以通過,但是在運(yùn)行時(shí)會(huì)直接崩潰或不起作用佑菩。
??下面的方法都沒有用了哦
// UITextField 的 _placeholderLabel
[textField setValue:[UIColor blackColor] forKeyPath:@"_placeholderLabel.textColor"];
// UISearchBar 的 _searchField
[searchBar valueForKey:@"_searchField"];
UITextField有一個(gè)attributedPlaceholder
屬性盾沫,占位符富文本,和UILabel等控件的富文本設(shè)置一樣殿漠,可以設(shè)置文字顏色赴精,尺寸等。
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設(shè)置textField問題
我們不用再用kvc獲取UISearchBar的textField了蕾哟,因?yàn)椋琲OS13中系統(tǒng)將searchTextField
屬性暴露出來了,不再是私有屬性了谭确,你可以直接調(diào)用帘营。
UITextField *searchField = _searchBar.searchTextField;
注意:以上寫法在iOS13以下手機(jī)運(yùn)行會(huì)崩潰,所以逐哈,暫時(shí)要寫成兩種情況的寫法芬迄,iOS13依然沿用之前的舊寫法。
用[[[UIDevice currentDevice] systemVersion] doubleValue] >= 13.0
加以區(qū)分
四昂秃、蘋果登錄 Sign In with Apple
關(guān)于蘋果登錄禀梳,如果應(yīng)用沒有使用第三方登錄,可以不用添加肠骆,如果已經(jīng)使用了第三方登錄(比如微信算途、QQ、微博等)蚀腿,就必須要加上蘋果登錄嘴瓤,且要放在最前面。
五唯咬、[_LSDefaults sharedInstance]崩潰
遇到'+[_LSDefaults sharedInstance]: unrecognized selector sent to class 0x1dd8f5d40'
崩潰問題纱注,可以嘗試~pod update
pod庫,暫時(shí)可以解決問題胆胰。