记录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方法里,

其他坑待更新

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值