1.模态弹出 iOS13之后,模态弹出控制器时,若未设置modalPresentationStyle,默认会使用UIModalPresentationPageSheet样式,这种样式并不会让页面拉满全屏(如图),不去适配的话真多格外的丑。
/** typedef NS_ENUM(NSInteger, UIModalPresentationStyle) { UIModalPresentationFullScreen = 0, // 全屏 UIModalPresentationPageSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos), UIModalPresentationFormSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos), UIModalPresentationCurrentContext API_AVAILABLE(ios(3.2)), // 全屏 UIModalPresentationCustom API_AVAILABLE(ios(7.0)), // 全屏 UIModalPresentationOverFullScreen API_AVAILABLE(ios(8.0)), // 全屏 UIModalPresentationOverCurrentContext API_AVAILABLE(ios(8.0)), // 全屏 UIModalPresentationPopover API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(tvos), UIModalPresentationBlurOverFullScreen API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios) API_UNAVAILABLE(watchos), UIModalPresentationNone API_AVAILABLE(ios(7.0)) = -1, UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2, }; typedef NS_ENUM(NSInteger, UIModalTransitionStyle) { UIModalTransitionStyleCoverVertical = 0, UIModalTransitionStyleFlipHorizontal API_UNAVAILABLE(tvos), UIModalTransitionStyleCrossDissolve, UIModalTransitionStylePartialCurl API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos), }; */ - (IBAction)tapButtonAciton:(id)sender { HomeViewController *home = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; // 展示风格 默认modalPresentationStyle=1即UIModalPresentationPageSheet home.modalPresentationStyle = UIModalPresentationFullScreen; // 跳转风格 home.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentViewController:home animated:YES completion:^{ }]; }默认展示样式
全屏样式
2.MVC 以前,我们在应用中使用了很多KVC的方式处理一些问题,比如修改UITextField占位文字的颜色和字体。
// 通过KVC修改占位文字的颜色和字体 [_textField setValue:[UIColor greenColor] forKeyPath:@"_placeholderLabel.textColor"]; [_textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];在iOS13之后,这种写法会直接崩溃。报错: Terminating app due to uncaught exception 'NSGenericException', reason: 'Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug'
// 需要换一种修改方式 NSDictionary *attDict = @{NSForegroundColorAttributeName:[UIColor greenColor], NSFontAttributeName:[UIFont systemFontOfSize:12]}; NSMutableAttributedString *arrStr = [[NSMutableAttributedString alloc] initWithString:_textField.placeholder attributes:attDict]; _textField.attributedPlaceholder = arrStr;3.友盟分享 友盟配置AppKey后线程崩溃,报错"[_LSDefaults sharedInstance]". 需要更新UMCShare到到版本6.9.6 不更了,更全面的,看大佬总结的"iOS 13 适配要点总结"