iOS13 新特性及其他变化

1.Dark Mode 暗黑模式

1.1 新增 Dark Mode

WeChata2026f7cc2551ae6f14f085135664078.png

1.2 UIColor拥有了动态属性

ios13之前.png

ios13以后.png

1.3 图片可以在两种模式下切换

image.png

1.4 Dark Mode 模式适配

暗黑模式适配OC

2.Status Bar更新

ios13之前Status Bar有两种状态:
UIStatusBarStyleDefault 文字黑色
UIStatusBarStyleLightContent 文字白色

ios13以后Status Bar有三种状态
UIStatusBarStyleDefault 自动选择黑色或白色
UIStatusBarStyleDarkContent 文字黑色
UIStatusBarStyleLightContent 文字白色

3.UIActivityIndicatorView加载视图

iOS13对UIActivityIndicatorView的样式也做了修改
ios13之前有三种样式:
UIActivityIndicatorViewStyleGray 灰色
UIActivityIndicatorViewStyleWhite 白色
UIActivityIndicatorViewStyleWhiteLarge 白色(大型)

iOS13废弃了以上三种样式,而用以下两种样式代替:
UIActivityIndicatorViewStyleLarge (大型)
UIActivityIndicatorViewStyleMedium (中型)

iOS13通过color属性设置其颜色

4.ios13之后的变化

4.1 presentViewController弹出样式

iOS13之前presentViewController弹出样式默认全屏。
iOS13以后弹出样式默认非全屏,若想全屏,设置modalPresentationStyle即可

UIViewcontroller *vc = [[UIViewcontroller alloc]init];
vc.modalPresentationStyle = UIModalPresentationFullScreen;
 [self presentViewController: vc animated:YES completion:nil];

4.2 增加了蓝牙一直使用的权限请求

解决方案:在info.plist里增加
NSBluetoothAlwaysUsageDescription
我们想要一直使用您的蓝牙功能来使定位更准确

4.3 UITextField的私有KVC

UITextField的私有KVC- (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath 会导致崩溃问题(其他的控件KVC可能也会导致崩溃问题,目前还未发现,请谨慎使用)
如:
[_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暗黑模式设置statusBarStyle不起作用

iOS 13.0暗黑模式运行后发现状态栏变为白色,设置[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault不起作用

解决方案:首先可能是 info.plist

UIViewControllerBasedStatusBarAppearance

将false换成true可以设置全局为黑色,但是如果部分界面需要用到白色的状态栏颜色,不能设置全局黑色,那么在最新的iOS13.0新增了状态栏颜色属性UIStatusBarStyleDarkContent

在需要设置成黑色的控制器中加入iOS 13.0的判断

-(void)viewWillAppear:(BOOL)animated{
    if (@available(iOS 13.0, *)) {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;

    } else {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    }
}

4.6 通过计算TabBar上的图片位置设置红点,红点位置有偏移

如果之前有通过TabBar上图片位置来设置红点位置,在iOS13上会发现显示位置都在最左边去了。遍历UITabBarButton的subViews发现只有在TabBar选中状态下才能取到UITabBarSwappableImageView,
解决方案:
通过UITabBarButton的位置来设置红点的frame。

4.7 UISearchBar显示问题

  1. 升级到iOS13,UISearchController上的SearchBar显示异常,查看后发现对应的高度只有1px,目前没找到具体导致的原因。

解决方案:
使用KVO监听frame值变化后设置去应该显示的高度,另外,也可能出现一些其他的显示问题,这个需要自己去一个个查看,在去解决相应的问题。

  1. 黑线处理crash
    之前为了处理搜索框的黑线问题会遍历后删除UISearchBarBackground,在iOS13会导致UI渲染失败crash;
    解决方案:
    设置UISearchBarBackground的layer.contents为nil

4.8 第三方登录强制使用苹果登录

在最新的iOS13.0后苹果强制加入了 Sign in with Apple(苹果登录),如果您的app中包含了其他的三方登录,那么这个苹果登录也需要加进去。

4.9 苹果停止了对UIWebview的维护,将全面替换成WKWebview

5. 其他新特性

5.1 iOS 13 中 tableView 和 collectionView 增加双指滑动编辑的功能

5.2 新增了文本的手势

新增了文本的手势,在原生控件中默认是生效的,可以禁止,选中文字后,可以操作复制和剪切 ,可以在光标的位置操作粘贴,还可以撤销,反撤销,呼出菜单
重写editingInteractionConfiguration方法可以选择禁止这些手势
复制:三指捏合
剪切:两次三指捏合
粘贴:三指松开
撤销:三指向左划动(或三指双击)
重做:三指向右划动
快捷菜单:三指单击

5.3 iOS 13新增了UIMenu控件

你可能感兴趣的:(iOS13 新特性及其他变化)