记录iOS13 所填的坑

年后回来就将开发设备,xcode都更新了,不更新还好,这一更新坑,真的是太坑了,

坑1. UITextField通过KVC访问的_placeholderLabe属性,竟然被禁止访问了

  1.     [_accountTextField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
  2.     [_accountTextField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];

l

解决:通过富文本的方式进行解决

  1. _accountTextField.attributedPlaceholder = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"userTips", nil) attributes:@{NSForegroundColorAttributeName : [UIColor redColor], NSFontAttributeName:[UIFont systemFontOfSize:13]}];

坑2. iOS 13  弃用statusBarWindow属性,导致设置状态栏的时候奔溃

  1. UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
  2. if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
  3.      statusBar.backgroundColor = [UIColor redColor];
  4.  }

解决:

  1. if (@available(iOS 13.0, *)) {
  2.          UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication     sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame] ;
  3.          statusBar.backgroundColor = [UIColor redColor];
  4.          [[UIApplication sharedApplication].keyWindow addSubview:statusBar];
  5.  
  6.     }else{
  7.         UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"]      valueForKey:@"statusBar"];
  8.         if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
  9.             statusBar.backgroundColor = [UIColor redColor];
  10.         }
  11.     }
  12.  

坑3.-(void)viewWillLayoutSubviews 中处理按钮里图标与文本的间距,在应用进入后台时会死循环,在进入应用就崩溃

  1. -(void)viewWillLayoutSubviews
  2. {
  3.     [super viewWillLayoutSubviews];
  4.     [_switchSkinBtn imageOnTheTitleRightWithSpace:0];//处理按钮里图标与文本的间距
  5.     NSLog(@"====>viewWillLayoutSubviews");
  6. }

解决:将处理按钮里图标与文本的间距的代码移到- (void)viewDidLoad方法里,

其他坑待更新

猜你喜欢

转载自blog.csdn.net/FF_lz/article/details/104491801