年后回来就将开发设备,xcode都更新了,不更新还好,这一更新坑,真的是太坑了,
坑1. UITextField通过KVC访问的_placeholderLabe属性,竟然被禁止访问了
- [_accountTextField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
- [_accountTextField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];
l
解决:通过富文本的方式进行解决
- _accountTextField.attributedPlaceholder = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"userTips", nil) attributes:@{NSForegroundColorAttributeName : [UIColor redColor], NSFontAttributeName:[UIFont systemFontOfSize:13]}];
坑2. iOS 13 弃用statusBarWindow属性,导致设置状态栏的时候奔溃
- UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
- if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
- statusBar.backgroundColor = [UIColor redColor];
- }
解决:
- if (@available(iOS 13.0, *)) {
- UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame] ;
- statusBar.backgroundColor = [UIColor redColor];
- [[UIApplication sharedApplication].keyWindow addSubview:statusBar];
- }else{
- UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
- if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
- statusBar.backgroundColor = [UIColor redColor];
- }
- }
坑3.-(void)viewWillLayoutSubviews 中处理按钮里图标与文本的间距,在应用进入后台时会死循环,在进入应用就崩溃
- -(void)viewWillLayoutSubviews
- {
- [super viewWillLayoutSubviews];
- [_switchSkinBtn imageOnTheTitleRightWithSpace:0];//处理按钮里图标与文本的间距
- NSLog(@"====>viewWillLayoutSubviews");
- }
解决:将处理按钮里图标与文本的间距的代码移到- (void)viewDidLoad方法里,
其他坑待更新