1.Dark Mode 暗黑模式
1.1 新增 Dark Mode

1.2 UIColor擁有了動態(tài)屬性


1.3 圖片可以在兩種模式下切換

1.4 Dark Mode 模式適配
2.Status Bar更新
ios13之前Status Bar有兩種狀態(tài):
UIStatusBarStyleDefault 文字黑色
UIStatusBarStyleLightContent 文字白色
ios13以后Status Bar有三種狀態(tài)
UIStatusBarStyleDefault 自動選擇黑色或白色
UIStatusBarStyleDarkContent 文字黑色
UIStatusBarStyleLightContent 文字白色
3.UIActivityIndicatorView加載視圖
iOS13對UIActivityIndicatorView的樣式也做了修改
ios13之前有三種樣式:
UIActivityIndicatorViewStyleGray 灰色
UIActivityIndicatorViewStyleWhite 白色
UIActivityIndicatorViewStyleWhiteLarge 白色(大型)
iOS13廢棄了以上三種樣式,而用以下兩種樣式代替:
UIActivityIndicatorViewStyleLarge (大型)
UIActivityIndicatorViewStyleMedium (中型)
iOS13通過color屬性設(shè)置其顏色
4.ios13之后的變化
4.1 presentViewController彈出樣式
iOS13之前presentViewController彈出樣式默認(rèn)全屏。
iOS13以后彈出樣式默認(rèn)非全屏,若想全屏,設(shè)置modalPresentationStyle即可
UIViewcontroller *vc = [[UIViewcontroller alloc]init];
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController: vc animated:YES completion:nil];
4.2 增加了藍(lán)牙一直使用的權(quán)限請求
解決方案:在info.plist里增加
<key>NSBluetoothAlwaysUsageDescription</key>
<string>我們想要一直使用您的藍(lán)牙功能來使定位更準(zhǔn)確</string>
4.3 UITextField的私有KVC
UITextField的私有KVC- (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath 會導(dǎo)致崩潰問題(其他的控件KVC可能也會導(dǎo)致崩潰問題,目前還未發(fā)現(xiàn),請謹(jǐn)慎使用)
如:
[_PhonetextField setValue:self.placeholdersColor forKeyPath:@"_placeholderLabel.textColor"];
解決方案
NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName : self.placeholderColor}]; _textField.attributedPlaceholder = placeholderString;
4.4 iOS 13.0獲取deviceToken方法更改
ios13之前
[[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""]
ios13以后
if (![deviceToken isKindOfClass:[NSData class]]) return;
const unsigned *tokenBytes = [deviceToken bytes];
NSString *deviceTokens = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
NSLog(@"deviceTokens:_______________%@",deviceTokens);
4.5 iOS 13.0暗黑模式設(shè)置statusBarStyle不起作用
iOS 13.0暗黑模式運行后發(fā)現(xiàn)狀態(tài)欄變?yōu)榘咨?,設(shè)置[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault不起作用
解決方案:首先可能是 info.plist
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
將false換成true可以設(shè)置全局為黑色,但是如果部分界面需要用到白色的狀態(tài)欄顏色,不能設(shè)置全局黑色,那么在最新的iOS13.0新增了狀態(tài)欄顏色屬性UIStatusBarStyleDarkContent
在需要設(shè)置成黑色的控制器中加入iOS 13.0的判斷
-(void)viewWillAppear:(BOOL)animated{
if (@available(iOS 13.0, *)) {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
} else {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
}
4.6 通過計算TabBar上的圖片位置設(shè)置紅點,紅點位置有偏移
如果之前有通過TabBar上圖片位置來設(shè)置紅點位置,在iOS13上會發(fā)現(xiàn)顯示位置都在最左邊去了。遍歷UITabBarButton的subViews發(fā)現(xiàn)只有在TabBar選中狀態(tài)下才能取到UITabBarSwappableImageView,
解決方案:
通過UITabBarButton的位置來設(shè)置紅點的frame。
4.7 UISearchBar顯示問題
- 升級到iOS13,UISearchController上的SearchBar顯示異常,查看后發(fā)現(xiàn)對應(yīng)的高度只有1px,目前沒找到具體導(dǎo)致的原因。
解決方案:
使用KVO監(jiān)聽frame值變化后設(shè)置去應(yīng)該顯示的高度,另外,也可能出現(xiàn)一些其他的顯示問題,這個需要自己去一個個查看,在去解決相應(yīng)的問題。
- 黑線處理crash
之前為了處理搜索框的黑線問題會遍歷后刪除UISearchBarBackground,在iOS13會導(dǎo)致UI渲染失敗crash;
解決方案:
設(shè)置UISearchBarBackground的layer.contents為nil
4.8 第三方登錄強(qiáng)制使用蘋果登錄
在最新的iOS13.0后蘋果強(qiáng)制加入了 Sign in with Apple(蘋果登錄),如果您的app中包含了其他的三方登錄,那么這個蘋果登錄也需要加進(jìn)去。
4.9 蘋果停止了對UIWebview的維護(hù),將全面替換成WKWebview
5. 其他新特性
5.1 iOS 13 中 tableView 和 collectionView 增加雙指滑動編輯的功能
5.2 新增了文本的手勢
新增了文本的手勢,在原生控件中默認(rèn)是生效的,可以禁止,選中文字后,可以操作復(fù)制和剪切 ,可以在光標(biāo)的位置操作粘貼,還可以撤銷,反撤銷,呼出菜單
重寫editingInteractionConfiguration方法可以選擇禁止這些手勢
復(fù)制:三指捏合
剪切:兩次三指捏合
粘貼:三指松開
撤銷:三指向左劃動(或三指雙擊)
重做:三指向右劃動
快捷菜單:三指單擊