iOS13部分适配

1、UIApplication的keyWindow被标记为API_DEPRECATED,获取的为nil

修改为[[[UIApplication sharedApplication] windows] objectAtIndex:0]

2、OS13中通过KVC方式来获取私有属性,有Carsh风险,访问私有变量崩溃,比如 UITextField * searchField =[_searchBar valueForKey:@"_searchField"];

在13中把SearchBar中的textField直接暴露给开发者使用,直接使用self.searchTextField;

    if ([self.textfield respondsToSelector:@selector(setAttributedPlaceholder:)]) {

        UIColor *color = kHBColorManager.kColorThreeLevelText;

        self.textfield.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName: color}];

    } else {

        self.textfield.placeholder = placeholder;

    }

禁止使用 [UITextField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor”];修改为attributedPlaceholder

你可能感兴趣的:(iOS13部分适配)